diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2018-06-15 18:20:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-15 18:20:55 -0400 |
commit | ee5ef309c7e2daef1248730145408f700732c42e (patch) | |
tree | b2de419dbdaf439eacb2295e767882384469d5fe /Lib/idlelib/idle_test/test_grep.py | |
parent | 6c5a4b315664f21bffc36ff6987fb4c4d1590897 (diff) | |
download | cpython-git-ee5ef309c7e2daef1248730145408f700732c42e.tar.gz |
bpo-33855: Minimally test all IDLE modules. (GH-7689)
Create a template for minimally testing a tkinter-using module by importing it and instantiating its class(es). Add a test file for all non-startup IDLE modules. Edit existing files and update coverage. This is part 1 of 3, covering the 21 autocomplete to help modules and touching 33 idlelib files.
Diffstat (limited to 'Lib/idlelib/idle_test/test_grep.py')
-rw-r--r-- | Lib/idlelib/idle_test/test_grep.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/idlelib/idle_test/test_grep.py b/Lib/idlelib/idle_test/test_grep.py index 6b54c13131..ab0d7860f7 100644 --- a/Lib/idlelib/idle_test/test_grep.py +++ b/Lib/idlelib/idle_test/test_grep.py @@ -3,14 +3,15 @@ Non-gui unit tests for grep.GrepDialog methods. dummy_command calls grep_it calls findfiles. An exception raised in one method will fail callers. Otherwise, tests are mostly independent. -*** Currently only test grep_it. +Currently only test grep_it, coverage 51%. """ +from idlelib.grep import GrepDialog import unittest from test.support import captured_stdout from idlelib.idle_test.mock_tk import Var -from idlelib.grep import GrepDialog import re + class Dummy_searchengine: '''GrepDialog.__init__ calls parent SearchDiabolBase which attaches the passed in SearchEngine instance as attribute 'engine'. Only a few of the @@ -21,6 +22,7 @@ class Dummy_searchengine: searchengine = Dummy_searchengine() + class Dummy_grep: # Methods tested #default_command = GrepDialog.default_command @@ -34,6 +36,7 @@ class Dummy_grep: grep = Dummy_grep() + class FindfilesTest(unittest.TestCase): # findfiles is really a function, not a method, could be iterator # test that filename return filename @@ -41,6 +44,7 @@ class FindfilesTest(unittest.TestCase): # test that recursive flag adds idle_test .py files pass + class Grep_itTest(unittest.TestCase): # Test captured reports with 0 and some hits. # Should test file names, but Windows reports have mixed / and \ separators @@ -71,10 +75,12 @@ class Grep_itTest(unittest.TestCase): self.assertIn('2', lines[3]) # hits found 2 self.assertTrue(lines[4].startswith('(Hint:')) + class Default_commandTest(unittest.TestCase): # To write this, move outwin import to top of GrepDialog # so it can be replaced by captured_stdout in class setup/teardown. pass + if __name__ == '__main__': - unittest.main(verbosity=2, exit=False) + unittest.main(verbosity=2) |