New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idle: test AutoExpand.py #62492
Comments
Continuing the IDLE unittest framework initiated in bpo-15392. Writing test for AutoExpand.py |
I am trying to improve the _decode function of mock Text class because most of the Idletests needs the mock text and requires some more features to handle indexes. |
Attached patch adds unittest for idlelib`s AutoExpand. Depends on bpo-18504 for Text's mocking abilities. |
For tests that use a Text widget, I want the first version to be a gui test using tkinter.Text. This removes mock Text as an issue in writing the tests. I will not commit without running the test 'live' at least once. Once the file (or at least a TestCase) is complete, we can then consider replacing the real Text with the mock. The gui code is commented out, rather than deleted, in case there is ever a need to switch back. See test_searchengine.py (bpo-18489), where this was done, (Even partial conversions are worthwhile if complete conversion is not possible.) Did I forget to say this in idle_test/README.txt? (I know I forget to mention this directly before now, Sorry ;-). Some modules import tkinter and instantiate widgets either upon import or during testing, (This is different from taking a widget instance as an argument in .__init__.) If so a gui-free test requires that the module be monkey-patched with mocks. For SearchEngine, the only widgets are XyzVars and TkMessageBox, for which we do have mocks. AutoExpand does not import tkinter, so it is fine as is. In your patch, comment out "from idlelib.idle_test.mock_tk import Text" and add the needed gui code. See the commented out code in |
Great start. The initial coveraqe is 90%, only missing the 5 lines in getwords in the bodies of I would like to cover those because I would like to later replace the dict instance dict (bad name!) with a set, 'seen'. 'dict.get(w)' would become 'w in seen'; 'dict[w] = w' would become 'seen.add(w)' Two comments: 1. Using 'previous' to detect the action of 'expand' is really clever.
I uploaded my version. See Rietveld diff for changes. Some notes: Leave out '-' after 'test-' in file name. Makes coverage call easier. getprevword only sees ascii chars when finding the word prefix. On the other hand, for 3.x, \w in getwords matches unicode chars for suffixes. If possible, getprevword should use \w to determine the prefix. Then 2.7 and 3.x should work on ascii and unicode respectively, with the same code. In a second stage, we should fix this and add tests with non-ascii chars (using \unnnn in literals). self.bell() makes no sound for me. How about you? A different non-critical nuisance. I start Idle in the debug interpreter with 'import idlelib.idle'. When root is destroyed, then the following is printed in the console interpreter after unittest is done. can't invoke "event" command: application has been destroyed I determined the timing by changing to 'exit=False' in unittest.main and adding 'time.sleep(2); print('done') after the u.main() call. Do you see anything like this? (Deleting the class attributes does not fix this.) tkinter.ttk in not in sys.modules, but perhaps something in one of the other modules directly accesses ttk at the tcl level when shutting down. |
Attached a patch incorporating changes from msg219661 and test-autoexp-18292.diff
|
New changeset bdbcd0ae0bde by Terry Jan Reedy in branch '2.7': New changeset bbdcf09e3097 by Terry Jan Reedy in branch '3.4': |
Coverage 100%. 2.7 version was easy, so committed after a few minor changes. We can revisit using the mock later. |
New changeset 2567c68fb300 by Zachary Ware in branch '2.7': |
Whoops. Zach, did you catch that by reading the checkin, running the test, or seeing a buildbot problem. Is not the first, what symptom on what system revealed the omission? |
Terry J. Reedy added the comment:
Buildbots; there were several red 2.7 bots and I got curious :). See |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: