Author terry.reedy
Recipients csabella, terry.reedy
Date 2017-06-10.02:47:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1497062869.85.0.550289391896.issue30617@psf.upfronthosting.co.za>
In-reply-to
Content
A1: yes, add
if __name__ == '__main__':
    import unittest
    unittest.main('idlelib.idle_test.test_outwin', verbosity=2, exit=False)

I will have to think about whether and how to add an htest.  The grep (find in files) test actually displays greps results in an outwin, and suggests rt clicking within the result window, so it really tests both grep and outwin modules.  Maybe this htest should be split.

A2. The current code tests whether the file exists *and* can be read.  It must have been read to appear in grep output.  But I am not sure this is true for names in tracebacks.  

B1. This is first test of an editor window.  Having the least code, it it probably the best place to start and learn ;-).

B2. The class level patterns are compiled to an instance array for each instance in which a user tries to go to file/line.  That should be most.  This looks to me like an attempted optimization (don't compile unless needed) that is a pessimization.  I think either A) the compiled patterns should be stored back on the class or B) raw and compiled patterns should be stored at module level.  They are not instance attributes and not really class attributes either.  Also, the code blocks that create file_line_progs and use it really belong in module level functions.  So lets try B.

Move stuff from class to module scope:

file_line_pats = [
   ...]
file_line_progs = None

def compile_progs():
    global file_line_progs
    file_line_progs = [re.compile(pat, re.IGNORECASE)
                       for pat in file_line_pats]

def find_file_line(line_of_text):
    <body of current _file_line_helper, with 'self.' deleted>

# and simply method
   def goto_file_line(self, event=None): # in class
        if not file_line_progs:
            compile_progs()

Test for compile_progs (:
    for pat, regex in zip(file_line_pats, file_line_progs):
        assertEqual(regex.pattern, pat)

Then feed find_file_line lines that should and should not match.  Try to find at least 1 true-to-life line for each pattern. 

B3. In re, \d "matches any Unicode decimal digit (that is, any character in Unicode character category [Nd])". Builtin int (at least) accepts strings consisting of string literal, which is restricted to ascii digit. msg90878 says "int and float currently accept characters in category 'Nd'".  I am not sure if that mean *all* Nd chars.  We could test.  If the exception is impossible, it should not be caught.  (Dead code should be removed, but we must be sure it is dead ;-)
History
Date User Action Args
2017-06-10 02:47:49terry.reedysetrecipients: + terry.reedy, csabella
2017-06-10 02:47:49terry.reedysetmessageid: <1497062869.85.0.550289391896.issue30617@psf.upfronthosting.co.za>
2017-06-10 02:47:49terry.reedylinkissue30617 messages
2017-06-10 02:47:47terry.reedycreate