Terry J. Reedy added the comment:
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 ;-)
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue30617>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com