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 Unit test for SearchEngine.py #62689
Comments
This test uses the mock text widget to search forwards and backwards, with and without wrapping. It also tests for empty matches with the 'ok' flag set in search_text(). The patch relies on the mock text tag_add function implemented in bpo-18226. |
Added tests for the rest of the SearchEngine module. I used the mock tkMessageBox for testing the error display, but used the tkinter Text widget for other tests because mark_set and tag_add/remove haven't been added to the mock yet. |
New changeset 310d187020e3 by Terry Jan Reedy in branch '2.7': New changeset cfb510884a13 by Terry Jan Reedy in branch '3.3': |
As with searchdialogbase tests, I get the following in the console every time I run the test file within idle. When I applied the patch, the tests ran, but left two tk windows. I added the missing root.destroy() calls. I plan to separate the class methods that search a text widget into a separate test case (or more). 10 lines are not yet covered. 6 should be easy. |
Big changes: monkey-patched module so tests of functions not using Text are non-gui; split search tests from other class tests as part of this. Several other little changes. The four lines still not covered are the bodies of |
The attached patch works on 3.3 and just need a small addition for 100$ coverage. After that, I intend to commit after porting to 2.7 (only two lines to change, I think) and testing it there. I split the search test case into three, one for each method. The tests for search_text repeated the tests for search_forward/backward. Simple mocks for the latter two allow to test for what search_text actually does: pick the right function to call and right starting point. The effect of the ok parameter is complicated because it has different effects in search_text and the other two (and less effect in search_backward than in search_forward because they are not symmetric). '\w+' never matches an empty string; so there was no test of 'ok=true' in search_forward. '\w*' can have empty matches and there now is a test. I discovered what seems to me a bug. If an initial null match is ignored, the search skips the rest of the line and skips to the next. This seems wrong but I am not sure what the proper behavior should be. I want to investigate the use of ok in the dialogs, especially the replace dialog before deciding The test of search_forward uses the mock Text. The remaining gui uses here (and many in other tests) could be eliminated with just a partial implementation of marks and selections, one that kept them fixed rather than moving them with insert and delete. So far we have been inserting text just once and then setting and getting things on a fixed text. |
Adding to test_search completed the coverage. |
New changeset 4179e2312089 by Terry Jan Reedy in branch '2.7': New changeset dfbf0f9034cc by Terry Jan Reedy in branch '3.3': New changeset 7605847c15a4 by Terry Jan Reedy in branch 'default': |
By masking mock Text.index with instance functions, I removed the need for tk.Text and hence the tests are gui free. |
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: