diff options
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_doctest.py | 29 | ||||
| -rw-r--r-- | Lib/test/test_ntpath.py | 3 | ||||
| -rw-r--r-- | Lib/test/test_optparse.py | 6 |
3 files changed, 34 insertions, 4 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py index f5a328e..89c878b 100644 --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -908,6 +908,35 @@ unexpected exception: ZeroDivisionError: integer division or modulo by zero TestResults(failed=1, attempted=1) """ + def displayhook(): r""" +Test that changing sys.displayhook doesn't matter for doctest. + + >>> import sys + >>> orig_displayhook = sys.displayhook + >>> def my_displayhook(x): + ... print('hi!') + >>> sys.displayhook = my_displayhook + >>> def f(): + ... ''' + ... >>> 3 + ... 3 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> r = doctest.DocTestRunner(verbose=False).run(test) + >>> post_displayhook = sys.displayhook + + We need to restore sys.displayhook now, so that we'll be able to test + results. + + >>> sys.displayhook = orig_displayhook + + Ok, now we can check that everything is ok. + + >>> r + TestResults(failed=0, attempted=1) + >>> post_displayhook is my_displayhook + True +""" def optionflags(): r""" Tests of `DocTestRunner`'s option flag handling. diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index 89b3f61..a421907 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -128,6 +128,9 @@ class TestNtpath(unittest.TestCase): self.assertTrue(isinstance(ntpath.normpath(path), unicode), 'normpath() returned str instead of unicode') + tester("ntpath.normpath('\\\\.\\NUL')", r'\\.\NUL') + tester("ntpath.normpath('\\\\?\\D:/XY\\Z')", r'\\?\D:/XY\Z') + def test_expandvars(self): oldenv = os.environ.copy() try: diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py index 641f37d..2fad442 100644 --- a/Lib/test/test_optparse.py +++ b/Lib/test/test_optparse.py @@ -799,15 +799,13 @@ class TestBool(BaseTest): (options, args) = self.assertParseOK(["-q"], {'verbose': 0}, []) - if hasattr(__builtins__, 'False'): - self.failUnless(options.verbose is False) + self.assertTrue(options.verbose is False) def test_bool_true(self): (options, args) = self.assertParseOK(["-v"], {'verbose': 1}, []) - if hasattr(__builtins__, 'True'): - self.failUnless(options.verbose is True) + self.assertTrue(options.verbose is True) def test_bool_flicker_on_and_off(self): self.assertParseOK(["-qvq", "-q", "-v"], |
