== CPython 3.6.0 (default, Jan 4 2017, 15:08:07) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] == Linux-2.6.32-642.6.2.el6.x86_64-x86_64-with-redhat-6.8-Santiago little-endian == hash algorithm: siphash24 64bit == cwd: /dev/shm/gerrit/Python-3.6.0/build/test_python_36964 == encodings: locale=UTF-8, FS=utf-8 Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0) Run tests sequentially 0:00:00 [1/1] test_doctest Trying: runner = DebugRunner(verbose=False) Expecting nothing ok Trying: test = DocTestParser().get_doctest('>>> raise KeyError\n42', {}, 'foo', 'foo.py', 0) Expecting nothing ok Trying: try: runner.run(test) except UnexpectedException as f: failure = f Expecting nothing ok Trying: failure.test is test Expecting: True ok Trying: failure.example.want Expecting: '42\n' ok Trying: exc_info = failure.exc_info Expecting nothing ok Trying: raise exc_info[1] # Already has the traceback Expecting: Traceback (most recent call last): ... KeyError ok Trying: test = DocTestParser().get_doctest(''' >>> x = 1 >>> x 2 ''', {}, 'foo', 'foo.py', 0) Expecting nothing ok Trying: try: runner.run(test) except DocTestFailure as f: failure = f Expecting nothing ok Trying: failure.test is test Expecting: True ok Trying: failure.example.want Expecting: '2\n' ok Trying: failure.got Expecting: '1\n' ok Trying: del test.globs['__builtins__'] Expecting nothing ok Trying: test.globs Expecting: {'x': 1} ok Trying: test = DocTestParser().get_doctest(''' >>> x = 2 >>> raise KeyError ''', {}, 'foo', 'foo.py', 0) Expecting nothing ok Trying: runner.run(test) Expecting: Traceback (most recent call last): ... doctest.UnexpectedException: ok Trying: del test.globs['__builtins__'] Expecting nothing ok Trying: test.globs Expecting: {'x': 2} ok Trying: test = DocTestParser().get_doctest(''' >>> x = 2 ''', {}, 'foo', 'foo.py', 0) Expecting nothing ok Trying: runner.run(test) Expecting: TestResults(failed=0, attempted=1) ok Trying: test.globs Expecting: {} ok Trying: test = DocTestParser().get_doctest('>>> raise KeyError\n42', {}, 'foo', 'foo.py', 0) Expecting nothing ok Trying: case = DocTestCase(test) Expecting nothing ok Trying: try: case.debug() except UnexpectedException as f: failure = f Expecting nothing ok Trying: failure.test is test Expecting: True ok Trying: failure.example.want Expecting: '42\n' ok Trying: exc_info = failure.exc_info Expecting nothing ok Trying: raise exc_info[1] # Already has the traceback Expecting: Traceback (most recent call last): ... KeyError ok Trying: test = DocTestParser().get_doctest(''' >>> x = 1 >>> x 2 ''', {}, 'foo', 'foo.py', 0) Expecting nothing ok Trying: case = DocTestCase(test) Expecting nothing ok Trying: try: case.debug() except DocTestFailure as f: failure = f Expecting nothing ok Trying: failure.test is test Expecting: True ok Trying: failure.example.want Expecting: '2\n' ok Trying: failure.got Expecting: '1\n' ok Trying: tests = DocTestFinder().find(_TestClass) Expecting nothing ok Trying: runner = DocTestRunner(verbose=False) Expecting nothing ok Trying: tests.sort(key = lambda test: test.name) Expecting nothing ok Trying: for test in tests: print(test.name, '->', runner.run(test)) Expecting: _TestClass -> TestResults(failed=0, attempted=2) _TestClass.__init__ -> TestResults(failed=0, attempted=2) _TestClass.get -> TestResults(failed=0, attempted=2) _TestClass.square -> TestResults(failed=0, attempted=1) ok Trying: runner.summarize(verbose=1) Expecting: 4 items passed all tests: 2 tests in _TestClass 2 tests in _TestClass.__init__ 2 tests in _TestClass.get 1 tests in _TestClass.square 7 tests in 4 items. 7 passed and 0 failed. Test passed. TestResults(failed=0, attempted=7) ok Trying: runner.tries Expecting: 7 ok Trying: runner.failures Expecting: 0 ok Trying: _TestClass(13).get() + _TestClass(-12).get() Expecting: 1 ok Trying: hex(_TestClass(13).square().get()) Expecting: '0xa9' ok Trying: t = _TestClass(123) Expecting nothing ok Trying: print(t.get()) Expecting: 123 ok Trying: x = _TestClass(-42) Expecting nothing ok Trying: print(x.get()) Expecting: -42 ok Trying: _TestClass(13).square().get() Expecting: 169 ok Trying: print('foo\n\nbar\n') Expecting: foo bar ok Trying: 4 == 4 Expecting: 1 ok Trying: 4 == 4 Expecting: True ok Trying: 4 > 4 Expecting: 0 ok Trying: 4 > 4 Expecting: False ok Trying: print(list(range(1000))) #doctest: +ELLIPSIS Expecting: [0, 1, 2, ..., 999] ok Trying: x = 1; y = 2 Expecting nothing ok Trying: x + y, x * y Expecting: (3, 2) ok Trying: print(list(range(30))) #doctest: +NORMALIZE_WHITESPACE Expecting: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29] ok Trying: _ellipsis_match('aa...aa', 'aaa') Expecting: False ok Trying: text = ''' Here are examples of simple math. Python has super accurate integer addition >>> 2 + 2 5 And very friendly error messages: >>> 1/0 To Infinity And Beyond You can use logic if you want: >>> if 0: ... blah ... blah ... Ho hum ''' Expecting nothing ok Trying: print(script_from_examples(text)) Expecting: # Here are examples of simple math. # # Python has super accurate integer addition # 2 + 2 # Expected: ## 5 # # And very friendly error messages: # 1/0 # Expected: ## To Infinity ## And ## Beyond # # You can use logic if you want: # if 0: blah blah # # Ho hum ok Trying: import doctest Expecting nothing ok Trying: old = doctest._unittest_reportflags Expecting nothing ok Trying: doctest.set_unittest_reportflags(REPORT_NDIFF | REPORT_ONLY_FIRST_FAILURE) == old Expecting: True ok Trying: doctest._unittest_reportflags == (REPORT_NDIFF | REPORT_ONLY_FIRST_FAILURE) Expecting: True ok Trying: doctest.set_unittest_reportflags(ELLIPSIS) Expecting: Traceback (most recent call last): ... ValueError: ('Only reporting flags allowed', 8) ok Trying: doctest.set_unittest_reportflags(old) == (REPORT_NDIFF | REPORT_ONLY_FIRST_FAILURE) Expecting: True ok 106 items had no tests: doctest doctest.DebugRunner.report_failure doctest.DebugRunner.report_unexpected_exception doctest.DebugRunner.run doctest.DocFileCase doctest.DocFileCase.__repr__ doctest.DocFileCase.format_failure doctest.DocFileCase.id doctest.DocFileSuite doctest.DocFileTest doctest.DocTest doctest.DocTest.__eq__ doctest.DocTest.__hash__ doctest.DocTest.__init__ doctest.DocTest.__lt__ doctest.DocTest.__repr__ doctest.DocTestCase doctest.DocTestCase.__eq__ doctest.DocTestCase.__hash__ doctest.DocTestCase.__init__ doctest.DocTestCase.__repr__ doctest.DocTestCase.format_failure doctest.DocTestCase.id doctest.DocTestCase.runTest doctest.DocTestCase.setUp doctest.DocTestCase.shortDescription doctest.DocTestCase.tearDown doctest.DocTestFailure doctest.DocTestFailure.__init__ doctest.DocTestFailure.__str__ doctest.DocTestFinder doctest.DocTestFinder.__init__ doctest.DocTestFinder._find doctest.DocTestFinder._find_lineno doctest.DocTestFinder._from_module doctest.DocTestFinder._get_test doctest.DocTestFinder.find doctest.DocTestParser doctest.DocTestParser._check_prefix doctest.DocTestParser._check_prompt_blank doctest.DocTestParser._find_options doctest.DocTestParser._min_indent doctest.DocTestParser._parse_example doctest.DocTestParser.get_doctest doctest.DocTestParser.get_examples doctest.DocTestParser.parse doctest.DocTestRunner._DocTestRunner__patched_linecache_getlines doctest.DocTestRunner._DocTestRunner__record_outcome doctest.DocTestRunner._DocTestRunner__run doctest.DocTestRunner.__init__ doctest.DocTestRunner._failure_header doctest.DocTestRunner.merge doctest.DocTestRunner.report_failure doctest.DocTestRunner.report_start doctest.DocTestRunner.report_success doctest.DocTestRunner.report_unexpected_exception doctest.DocTestRunner.run doctest.DocTestRunner.summarize doctest.DocTestSuite doctest.Example doctest.Example.__eq__ doctest.Example.__hash__ doctest.Example.__init__ doctest.OutputChecker doctest.OutputChecker._do_a_fancy_diff doctest.OutputChecker._toAscii doctest.OutputChecker.check_output doctest.OutputChecker.output_difference doctest.SkipDocTestCase doctest.SkipDocTestCase.__init__ doctest.SkipDocTestCase.setUp doctest.SkipDocTestCase.shortDescription doctest.SkipDocTestCase.test_skip doctest.TestResults doctest.TestResults.attempted doctest.TestResults.failed doctest.UnexpectedException doctest.UnexpectedException.__init__ doctest.UnexpectedException.__str__ doctest._DocTestSuite doctest._DocTestSuite._removeTestAtIndex doctest._OutputRedirectingPdb doctest._OutputRedirectingPdb.__init__ doctest._OutputRedirectingPdb.set_continue doctest._OutputRedirectingPdb.set_trace doctest._OutputRedirectingPdb.trace_dispatch doctest._SpoofOut doctest._SpoofOut.getvalue doctest._SpoofOut.truncate doctest._comment_line doctest._exception_traceback doctest._extract_future_flags doctest._indent doctest._load_testfile doctest._module_relative_path doctest._normalize_module doctest._strip_exception_details doctest._test doctest.debug doctest.debug_script doctest.debug_src doctest.register_optionflag doctest.run_docstring_examples doctest.testfile doctest.testmod doctest.testsource 15 items passed all tests: 21 tests in doctest.DebugRunner 13 tests in doctest.DocTestCase.debug 7 tests in doctest.DocTestRunner 2 tests in doctest._TestClass 2 tests in doctest._TestClass.__init__ 2 tests in doctest._TestClass.get 1 tests in doctest._TestClass.square 1 tests in doctest.__test__.blank lines 4 tests in doctest.__test__.bool-int equivalence 1 tests in doctest.__test__.ellipsis 2 tests in doctest.__test__.string 1 tests in doctest.__test__.whitespace normalization 1 tests in doctest._ellipsis_match 2 tests in doctest.script_from_examples 6 tests in doctest.set_unittest_reportflags 66 tests in 121 items. 66 passed and 0 failed. Test passed. doctest (doctest) ... 66 tests with zero failures Trying: print(1) Expecting: 1 ok Trying: sc = SampleClass(3) Expecting nothing ok Trying: for i in range(10): sc = sc.double() print(' ', sc.get(), sep='', end='') Expecting: 6 12 24 48 96 192 384 768 1536 3072 ok Trying: x = SampleClass.NestedClass(5) Expecting nothing ok Trying: y = x.square() Expecting nothing ok Trying: print(y.get()) Expecting: 25 ok Trying: print(SampleClass.NestedClass().get()) Expecting: 0 ok Trying: print(SampleClass(12).get()) Expecting: 12 ok Trying: print(SampleClass.a_classmethod(10)) Expecting: 12 ok Trying: print(SampleClass(0).a_classmethod(10)) Expecting: 12 ok Trying: print(SampleClass(22).a_property) Expecting: 22 ok Trying: print(SampleClass.a_staticmethod(10)) Expecting: 11 ok Trying: print(SampleClass(12).double().get()) Expecting: 24 ok Trying: print(SampleClass(-5).get()) Expecting: -5 ok Trying: print('1\n2\n3') Expecting: 1 2 3 ok Trying: print(SampleNewStyleClass(12).get()) Expecting: 12 ok Trying: print(SampleNewStyleClass(12).double().get()) Expecting: 24 ok Trying: print(SampleNewStyleClass(-5).get()) Expecting: -5 ok Trying: print(sample_func(22)) Expecting: 44 ok Trying: def normalize(s): return '\n'.join(s.decode().splitlines()) Expecting nothing ok Trying: from test.support import script_helper, temp_dir Expecting nothing ok Trying: with temp_dir() as tmpdir: fn = os.path.join(tmpdir, 'myfile.doc') with open(fn, 'w') as f: _ = f.write('This is a very simple test file.\n') _ = f.write(' >>> 1 + 1\n') _ = f.write(' 2\n') _ = f.write(' >>> "a"\n') _ = f.write(" 'a'\n") _ = f.write('\n') _ = f.write('And that is it.\n') rc1, out1, err1 = script_helper.assert_python_ok( '-m', 'doctest', fn) rc2, out2, err2 = script_helper.assert_python_ok( '-m', 'doctest', '-v', fn) Expecting nothing ok Trying: rc1, out1, err1 Expecting: (0, b'', b'') ok Trying: rc2, err2 Expecting: (0, b'') ok Trying: print(normalize(out2)) Expecting: Trying: 1 + 1 Expecting: 2 ok Trying: "a" Expecting: 'a' ok 1 items passed all tests: 2 tests in myfile.doc 2 tests in 1 items. 2 passed and 0 failed. Test passed. ok Trying: from test.support import script_helper, temp_dir Expecting nothing ok Trying: with temp_dir() as tmpdir: fn = os.path.join(tmpdir, 'myfile.doc') with open(fn, 'w') as f: _ = f.write('This is another simple test file.\n') _ = f.write(' >>> 1 + 1\n') _ = f.write(' 2\n') _ = f.write(' >>> "abcdef"\n') _ = f.write(" 'a...f'\n") _ = f.write(' >>> "ajkml"\n') _ = f.write(" 'a...l'\n") _ = f.write('\n') _ = f.write('And that is it.\n') fn2 = os.path.join(tmpdir, 'myfile2.py') with open(fn2, 'w') as f: _ = f.write('def test_func():\n') _ = f.write(' \"\"\"\n') _ = f.write(' This is simple python test function.\n') _ = f.write(' >>> 1 + 1\n') _ = f.write(' 2\n') _ = f.write(' >>> "abc def"\n') _ = f.write(" 'abc def'\n") _ = f.write("\n") _ = f.write(' \"\"\"\n') rc1, out1, err1 = script_helper.assert_python_failure( '-m', 'doctest', fn, fn2) rc2, out2, err2 = script_helper.assert_python_ok( '-m', 'doctest', '-o', 'ELLIPSIS', fn) rc3, out3, err3 = script_helper.assert_python_ok( '-m', 'doctest', '-o', 'ELLIPSIS', '-o', 'NORMALIZE_WHITESPACE', fn, fn2) rc4, out4, err4 = script_helper.assert_python_failure( '-m', 'doctest', '-f', fn, fn2) rc5, out5, err5 = script_helper.assert_python_ok( '-m', 'doctest', '-v', '-o', 'ELLIPSIS', '-o', 'NORMALIZE_WHITESPACE', fn, fn2) Expecting nothing ok Trying: rc1, err1 Expecting: (1, b'') ok Trying: print(normalize(out1)) # doctest: +ELLIPSIS Expecting: ********************************************************************** File "...myfile.doc", line 4, in myfile.doc Failed example: "abcdef" Expected: 'a...f' Got: 'abcdef' ********************************************************************** File "...myfile.doc", line 6, in myfile.doc Failed example: "ajkml" Expected: 'a...l' Got: 'ajkml' ********************************************************************** 1 items had failures: 2 of 3 in myfile.doc ***Test Failed*** 2 failures. ok Trying: rc2, out2, err2 Expecting: (0, b'', b'') ok Trying: rc3, out3, err3 Expecting: (0, b'', b'') ok Trying: rc4, err4 Expecting: (1, b'') ok Trying: print(normalize(out4)) # doctest: +ELLIPSIS Expecting: ********************************************************************** File "...myfile.doc", line 4, in myfile.doc Failed example: "abcdef" Expected: 'a...f' Got: 'abcdef' ********************************************************************** 1 items had failures: 1 of 2 in myfile.doc ***Test Failed*** 1 failures. ok Trying: rc5, err5 Expecting: (0, b'') ok Trying: print(normalize(out5)) Expecting: Trying: 1 + 1 Expecting: 2 ok Trying: "abcdef" Expecting: 'a...f' ok Trying: "ajkml" Expecting: 'a...l' ok 1 items passed all tests: 3 tests in myfile.doc 3 tests in 1 items. 3 passed and 0 failed. Test passed. Trying: 1 + 1 Expecting: 2 ok Trying: "abc def" Expecting: 'abc def' ok 1 items had no tests: myfile2 1 items passed all tests: 2 tests in myfile2.test_func 2 tests in 2 items. 2 passed and 0 failed. Test passed. ok Trying: rc, out, err = script_helper.assert_python_failure( '-m', 'doctest', 'nosuchfile') Expecting nothing ok Trying: rc, out Expecting: (1, b'') ok Trying: print(normalize(err)) # doctest: +ELLIPSIS Expecting: Traceback (most recent call last): ... FileNotFoundError: [Errno ...] No such file or directory: 'nosuchfile' ok Trying: rc, out, err = script_helper.assert_python_failure( '-m', 'doctest', '-o', 'nosuchoption') Expecting nothing ok Trying: rc, out Expecting: (2, b'') ok Trying: print(normalize(err)) # doctest: +ELLIPSIS Expecting: usage...invalid...nosuchoption... ok Trying: import unittest Expecting nothing ok Trying: suite = doctest.DocFileSuite('test_doctest.txt', 'test_doctest2.txt', 'test_doctest4.txt') Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: import unittest Expecting nothing ok Trying: suite = doctest.DocFileSuite('test_doctest.txt', 'test_doctest2.txt', 'test_doctest4.txt', package='test') Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: import unittest, pkgutil, test Expecting nothing ok Trying: added_loader = False Expecting nothing ok Trying: if not hasattr(test, '__loader__'): test.__loader__ = pkgutil.get_loader(test) added_loader = True Expecting nothing ok Trying: try: suite = doctest.DocFileSuite('test_doctest.txt', 'test_doctest2.txt', 'test_doctest4.txt', package='test') suite.run(unittest.TestResult()) finally: if added_loader: del test.__loader__ Expecting: ok Trying: suite = doctest.DocFileSuite('../test/test_doctest.txt') Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: import types, os.path, test.test_doctest Expecting nothing ok Trying: save_argv = sys.argv Expecting nothing ok Trying: sys.argv = [test.test_doctest.__file__] Expecting nothing ok Trying: suite = doctest.DocFileSuite('test_doctest.txt', package=types.ModuleType('__main__')) Expecting nothing ok Trying: sys.argv = save_argv Expecting nothing ok Trying: test_doctest_path = os.path.abspath(test.test_doctest.__file__) Expecting nothing ok Trying: test_pkg_path = os.path.split(test_doctest_path)[0] Expecting nothing ok Trying: test_file = os.path.join(test_pkg_path, 'test_doctest.txt') Expecting nothing ok Trying: suite = doctest.DocFileSuite(test_file, module_relative=False) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: suite = doctest.DocFileSuite(test_file, module_relative=False, package='test') Expecting: Traceback (most recent call last): ValueError: Package may only be specified for module-relative paths. ok Trying: suite = doctest.DocFileSuite('test_doctest.txt', 'test_doctest2.txt', 'test_doctest4.txt', globs={'favorite_color': 'blue'}) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: suite = doctest.DocFileSuite('test_doctest.txt', 'test_doctest2.txt', 'test_doctest4.txt', optionflags=doctest.DONT_ACCEPT_BLANKLINE, globs={'favorite_color': 'blue'}) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: def setUp(t): import test.test_doctest test.test_doctest.sillySetup = True Expecting nothing ok Trying: def tearDown(t): import test.test_doctest del test.test_doctest.sillySetup Expecting nothing ok Trying: suite = doctest.DocFileSuite('test_doctest.txt', 'test_doctest2.txt', 'test_doctest4.txt', setUp=setUp, tearDown=tearDown) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: import test.test_doctest Expecting nothing ok Trying: test.test_doctest.sillySetup Expecting: Traceback (most recent call last): ... AttributeError: module 'test.test_doctest' has no attribute 'sillySetup' ok Trying: def setUp(test): test.globs['favorite_color'] = 'blue' Expecting nothing ok Trying: suite = doctest.DocFileSuite('test_doctest.txt', setUp=setUp) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: suite = doctest.DocFileSuite('test_doctest3.txt') Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: suite = doctest.DocFileSuite('test_doctest.txt', 'test_doctest2.txt', 'test_doctest4.txt', encoding='utf-8') Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: docstring = ''' >>> print(12) 12 Non-example text. >>> print('another\\example') another example ''' Expecting nothing ok Trying: globs = {} # globals to run the test in. Expecting nothing ok Trying: parser = doctest.DocTestParser() Expecting nothing ok Trying: test = parser.get_doctest(docstring, globs, 'some_test', 'some_file', 20) Expecting nothing ok Trying: print(test) Expecting: ok Trying: len(test.examples) Expecting: 2 ok Trying: e1, e2 = test.examples Expecting nothing ok Trying: (e1.source, e1.want, e1.lineno) Expecting: ('print(12)\n', '12\n', 1) ok Trying: (e2.source, e2.want, e2.lineno) Expecting: ("print('another\\example')\n", 'another\nexample\n', 6) ok Trying: (test.name, test.filename, test.lineno) Expecting: ('some_test', 'some_file', 20) ok Trying: test.lineno + e1.lineno Expecting: 21 ok Trying: test.lineno + e2.lineno Expecting: 26 ok Trying: docstring = r''' >>> print('bad\nindentation') bad indentation ''' Expecting nothing ok Trying: parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Expecting: Traceback (most recent call last): ValueError: line 4 of the docstring for some_test has inconsistent leading whitespace: 'indentation' ok Trying: docstring = r''' >>> print(('bad indentation', ... 2)) ('bad', 'indentation') ''' Expecting nothing ok Trying: parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Expecting: Traceback (most recent call last): ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: '... 2))' ok Trying: docstring = '>>>print(1)\n1' Expecting nothing ok Trying: parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Expecting: Traceback (most recent call last): ValueError: line 1 of the docstring for some_test lacks blank after >>>: '>>>print(1)' ok Trying: docstring = '>>> if 1:\n...print(1)\n1' Expecting nothing ok Trying: parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Expecting: Traceback (most recent call last): ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print(1)' ok Trying: docstring = ''' >>> print 12 12 ''' Expecting nothing ok Trying: test = parser.get_doctest(docstring, globs, 'some_test', 'some_test', 20) Expecting nothing ok Trying: same_test = parser.get_doctest(docstring, globs, 'some_test', 'some_test', 20) Expecting nothing ok Trying: test == same_test Expecting: True ok Trying: test != same_test Expecting: False ok Trying: hash(test) == hash(same_test) Expecting: True ok Trying: docstring = ''' >>> print 42 42 ''' Expecting nothing ok Trying: other_test = parser.get_doctest(docstring, globs, 'other_test', 'other_file', 10) Expecting nothing ok Trying: test == other_test Expecting: False ok Trying: test != other_test Expecting: True ok Trying: DocTestCase = doctest.DocTestCase Expecting nothing ok Trying: test_case = DocTestCase(test) Expecting nothing ok Trying: same_test_case = DocTestCase(same_test) Expecting nothing ok Trying: other_test_case = DocTestCase(other_test) Expecting nothing ok Trying: test_case == same_test_case Expecting: True ok Trying: test_case != same_test_case Expecting: False ok Trying: hash(test_case) == hash(same_test_case) Expecting: True ok Trying: test == other_test_case Expecting: False ok Trying: test != other_test_case Expecting: True ok Trying: finder = doctest.DocTestFinder() Expecting nothing ok Trying: import test.test_doctest Expecting nothing ok Trying: old = test.test_doctest.__file__ Expecting nothing ok Trying: test.test_doctest.__file__ = 'test_doctest.pyc' Expecting nothing ok Trying: tests = finder.find(sample_func) Expecting nothing ok Trying: print(tests) # doctest: +ELLIPSIS Expecting: [] ok Trying: tests[0].filename # doctest: +ELLIPSIS Expecting: '...test_doctest.py' ok Trying: test.test_doctest.__file__ = old Expecting nothing ok Trying: e = tests[0].examples[0] Expecting nothing ok Trying: (e.source, e.want, e.lineno) Expecting: ('print(sample_func(22))\n', '44\n', 3) ok Trying: def no_docstring(v): pass Expecting nothing ok Trying: finder.find(no_docstring) Expecting: [] ok Trying: def no_docstring(v): pass Expecting nothing ok Trying: excl_empty_finder = doctest.DocTestFinder(exclude_empty=True) Expecting nothing ok Trying: excl_empty_finder.find(no_docstring) Expecting: [] ok Trying: def no_examples(v): ''' no doctest examples ''' Expecting nothing ok Trying: finder.find(no_examples) # doctest: +ELLIPSIS Expecting: [] ok Trying: finder = doctest.DocTestFinder() Expecting nothing ok Trying: tests = finder.find(SampleClass) Expecting nothing ok Trying: for t in tests: print('%2s %s' % (len(t.examples), t.name)) Expecting: 3 SampleClass 3 SampleClass.NestedClass 1 SampleClass.NestedClass.__init__ 1 SampleClass.__init__ 2 SampleClass.a_classmethod 1 SampleClass.a_property 1 SampleClass.a_staticmethod 1 SampleClass.double 1 SampleClass.get ok Trying: tests = finder.find(SampleNewStyleClass) Expecting nothing ok Trying: for t in tests: print('%2s %s' % (len(t.examples), t.name)) Expecting: 1 SampleNewStyleClass 1 SampleNewStyleClass.__init__ 1 SampleNewStyleClass.double 1 SampleNewStyleClass.get ok Trying: import types Expecting nothing ok Trying: m = types.ModuleType('some_module') Expecting nothing ok Trying: def triple(val): ''' >>> print(triple(11)) 33 ''' return val*3 Expecting nothing ok Trying: m.__dict__.update({ 'sample_func': sample_func, 'SampleClass': SampleClass, '__doc__': ''' Module docstring. >>> print('module') module ''', '__test__': { 'd': '>>> print(6)\n6\n>>> print(7)\n7\n', 'c': triple}}) Expecting nothing ok Trying: finder = doctest.DocTestFinder() Expecting nothing ok Trying: import test.test_doctest Expecting nothing ok Trying: tests = finder.find(m, module=test.test_doctest) Expecting nothing ok Trying: for t in tests: print('%2s %s' % (len(t.examples), t.name)) Expecting: 1 some_module 3 some_module.SampleClass 3 some_module.SampleClass.NestedClass 1 some_module.SampleClass.NestedClass.__init__ 1 some_module.SampleClass.__init__ 2 some_module.SampleClass.a_classmethod 1 some_module.SampleClass.a_property 1 some_module.SampleClass.a_staticmethod 1 some_module.SampleClass.double 1 some_module.SampleClass.get 1 some_module.__test__.c 2 some_module.__test__.d 1 some_module.sample_func ok Trying: from test import doctest_aliases Expecting nothing ok Trying: assert doctest_aliases.TwoNames.f Expecting nothing ok Trying: assert doctest_aliases.TwoNames.g Expecting nothing ok Trying: tests = excl_empty_finder.find(doctest_aliases) Expecting nothing ok Trying: print(len(tests)) Expecting: 2 ok Trying: print(tests[0].name) Expecting: test.doctest_aliases.TwoNames ok Trying: tests[1].name.split('.')[-1] in ['f', 'g'] Expecting: True ok Trying: tests = doctest.DocTestFinder().find(SampleClass) Expecting nothing ok Trying: for t in tests: print('%2s %s' % (len(t.examples), t.name)) Expecting: 3 SampleClass 3 SampleClass.NestedClass 1 SampleClass.NestedClass.__init__ 1 SampleClass.__init__ 2 SampleClass.a_classmethod 1 SampleClass.a_property 1 SampleClass.a_staticmethod 1 SampleClass.double 1 SampleClass.get ok Trying: tests = doctest.DocTestFinder(exclude_empty=False).find(SampleClass) Expecting nothing ok Trying: for t in tests: print('%2s %s' % (len(t.examples), t.name)) Expecting: 3 SampleClass 3 SampleClass.NestedClass 1 SampleClass.NestedClass.__init__ 0 SampleClass.NestedClass.get 0 SampleClass.NestedClass.square 1 SampleClass.__init__ 2 SampleClass.a_classmethod 1 SampleClass.a_property 1 SampleClass.a_staticmethod 1 SampleClass.double 1 SampleClass.get ok Trying: tests = doctest.DocTestFinder(recurse=False).find(SampleClass) Expecting nothing ok Trying: for t in tests: print('%2s %s' % (len(t.examples), t.name)) Expecting: 3 SampleClass ok Trying: def f(x): ''' >>> x = 12 some text >>> # examples are not created for comments & bare prompts. >>> ... >>> for x in range(10): ... print(x, end=' ') 0 1 2 3 4 5 6 7 8 9 >>> x//2 6 ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: [e.lineno for e in test.examples] Expecting: [1, 9, 12] ok Trying: import builtins Expecting nothing ok Trying: tests = doctest.DocTestFinder().find(builtins) Expecting nothing ok Trying: 790 < len(tests) < 810 # approximate number of objects with docstrings Expecting: True ok Trying: real_tests = [t for t in tests if len(t.examples) > 0] Expecting nothing ok Trying: len(real_tests) # objects that actually have doctests Expecting: 8 ok Trying: for t in real_tests: print('{} {}'.format(len(t.examples), t.name)) Expecting: 1 builtins.bin 3 builtins.float.as_integer_ratio 2 builtins.float.fromhex 2 builtins.float.hex 1 builtins.hex 1 builtins.int 2 builtins.int.bit_length 1 builtins.oct ok Trying: s = ''' >>> x, y = 2, 3 # no output expected >>> if 1: ... print(x) ... print(y) 2 3 Some text. >>> x+y 5 ''' Expecting nothing ok Trying: parser = doctest.DocTestParser() Expecting nothing ok Trying: for piece in parser.parse(s): if isinstance(piece, doctest.Example): print('Example:', (piece.source, piece.want, piece.lineno)) else: print(' Text:', repr(piece)) Expecting: Text: '\n' Example: ('x, y = 2, 3 # no output expected\n', '', 1) Text: '' Example: ('if 1:\n print(x)\n print(y)\n', '2\n3\n', 2) Text: '\nSome text.\n' Example: ('x+y\n', '5\n', 9) Text: '' ok Trying: for piece in parser.get_examples(s): print((piece.source, piece.want, piece.lineno)) Expecting: ('x, y = 2, 3 # no output expected\n', '', 1) ('if 1:\n print(x)\n print(y)\n', '2\n3\n', 2) ('x+y\n', '5\n', 9) ok Trying: test = parser.get_doctest(s, {}, 'name', 'filename', lineno=5) Expecting nothing ok Trying: (test.name, test.filename, test.lineno) Expecting: ('name', 'filename', 5) ok Trying: for piece in test.examples: print((piece.source, piece.want, piece.lineno)) Expecting: ('x, y = 2, 3 # no output expected\n', '', 1) ('if 1:\n print(x)\n print(y)\n', '2\n3\n', 2) ('x+y\n', '5\n', 9) ok Trying: def f(x): ''' >>> x = 12 >>> print(x) 12 >>> x//2 6 ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=3) ok Trying: def f(x): ''' >>> x = 12 >>> print(x) 14 >>> x//2 6 ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=True).run(test) # doctest: +ELLIPSIS Expecting: Trying: x = 12 Expecting nothing ok Trying: print(x) Expecting: 14 ********************************************************************** File ..., line 4, in f Failed example: print(x) Expected: 14 Got: 12 Trying: x//2 Expecting: 6 ok TestResults(failed=1, attempted=3) ok Trying: import sys Expecting nothing ok Trying: orig_displayhook = sys.displayhook Expecting nothing ok Trying: def my_displayhook(x): print('hi!') Expecting nothing ok Trying: sys.displayhook = my_displayhook Expecting nothing ok Trying: def f(): ''' >>> 3 3 ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: r = doctest.DocTestRunner(verbose=False).run(test) Expecting nothing ok Trying: post_displayhook = sys.displayhook Expecting nothing ok Trying: sys.displayhook = orig_displayhook Expecting nothing ok Trying: r Expecting: TestResults(failed=0, attempted=1) ok Trying: post_displayhook is my_displayhook Expecting: True ok Trying: def f(x): ''' >>> x = 12 >>> print(x//0) Traceback (most recent call last): ZeroDivisionError: integer division or modulo by zero ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=2) ok Trying: def f(x): ''' >>> x = 12 >>> print('pre-exception output', x//0) pre-exception output Traceback (most recent call last): ZeroDivisionError: integer division or modulo by zero ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 4, in f Failed example: print('pre-exception output', x//0) Exception raised: ... ZeroDivisionError: integer division or modulo by zero TestResults(failed=1, attempted=2) ok Trying: def f(x): r''' >>> raise ValueError('multi\nline\nmessage') Traceback (most recent call last): ValueError: multi line message ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=1) ok Trying: def f(x): r''' >>> raise ValueError('message') Traceback (most recent call last): ValueError: wrong message ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 3, in f Failed example: raise ValueError('message') Expected: Traceback (most recent call last): ValueError: wrong message Got: Traceback (most recent call last): ... ValueError: message TestResults(failed=1, attempted=1) ok Trying: def f(x): r''' >>> raise ValueError('message') #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ValueError: wrong message ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=1) ok Trying: def f(x): r''' >>> from http.client import HTTPException >>> raise HTTPException('message') Traceback (most recent call last): HTTPException: message ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 4, in f Failed example: raise HTTPException('message') Expected: Traceback (most recent call last): HTTPException: message Got: Traceback (most recent call last): ... http.client.HTTPException: message TestResults(failed=1, attempted=2) ok Trying: def f(x): r''' >>> from http.client import HTTPException >>> raise HTTPException('message') Traceback (most recent call last): http.client.HTTPException: message ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=2) ok Trying: def f(x): r''' >>> from http.client import HTTPException >>> raise HTTPException('message') #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): HTTPException: message ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=2) ok Trying: def f(x): r''' >>> from http.client import HTTPException >>> raise HTTPException('message') #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): foo.bar.HTTPException: message ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=2) ok Trying: def f(x): r''' >>> raise ValueError('message') #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): TypeError: wrong type ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 3, in f Failed example: raise ValueError('message') #doctest: +IGNORE_EXCEPTION_DETAIL Expected: Traceback (most recent call last): TypeError: wrong type Got: Traceback (most recent call last): ... ValueError: message TestResults(failed=1, attempted=1) ok Trying: def f(x): r''' >>> from http.client import HTTPException >>> raise HTTPException() #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): foo.bar.HTTPException ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=2) ok Trying: def f(x): r''' >>> from http.client import HTTPException >>> raise HTTPException() #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): foo.bar.HTTPException: ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=2) ok Trying: def f(x): r''' >>> 1//0 0 ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 3, in f Failed example: 1//0 Exception raised: Traceback (most recent call last): ... ZeroDivisionError: integer division or modulo by zero TestResults(failed=1, attempted=1) ok Trying: def f(x): r''' >>> print(list(range(10))) # should fail: no ellipsis [0, 1, ..., 9] >>> print(list(range(10))) # doctest: +ELLIPSIS [0, 1, ..., 9] ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 2, in f Failed example: print(list(range(10))) # should fail: no ellipsis Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TestResults(failed=1, attempted=2) ok Trying: def f(x): r''' >>> print(list(range(10))) [0, 1, ..., 9] >>> # should fail: no ellipsis >>> print(list(range(10))) # doctest: -ELLIPSIS [0, 1, ..., 9] ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=doctest.ELLIPSIS).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 6, in f Failed example: print(list(range(10))) # doctest: -ELLIPSIS Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TestResults(failed=1, attempted=2) ok Trying: def f(x): r''' >>> print(list(range(10))) # Should fail: no ellipsis [0, 1, ..., 9] >>> print(list(range(10))) # doctest: +ELLIPSIS [0, 1, ..., 9] >>> print(list(range(10))) # Should fail: no ellipsis [0, 1, ..., 9] ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 2, in f Failed example: print(list(range(10))) # Should fail: no ellipsis Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ********************************************************************** File ..., line 8, in f Failed example: print(list(range(10))) # Should fail: no ellipsis Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TestResults(failed=2, attempted=3) ok Trying: def f(x): r''' >>> print(list(range(10))) # Should fail [0, 1, ..., 9] >>> print(list(range(10))) # Should succeed ... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE [0, 1, ..., 9] ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 2, in f Failed example: print(list(range(10))) # Should fail Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TestResults(failed=1, attempted=2) ok Trying: def f(x): r''' >>> print(list(range(10))) # Should fail [0, 1, ..., 9] >>> print(list(range(10))) # Should succeed ... # doctest: +ELLIPSIS,+NORMALIZE_WHITESPACE [0, 1, ..., 9] ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 2, in f Failed example: print(list(range(10))) # Should fail Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TestResults(failed=1, attempted=2) ok Trying: def f(x): r''' >>> print(list(range(10))) # Should fail [0, 1, ..., 9] >>> print(list(range(10))) # Should succeed ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE [0, 1, ..., 9] ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 2, in f Failed example: print(list(range(10))) # Should fail Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TestResults(failed=1, attempted=2) ok Trying: def f(x): r''' >>> print(list(range(10))) ... # doctest: +ELLIPSIS [0, 1, ..., 9] ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=1) ok Trying: def f(x): r''' >>> for x in range(10): # doctest: +ELLIPSIS ... print(' ', x, end='', sep='') 0 1 2 ... 9 >>> for x in range(10): ... print(' ', x, end='', sep='') # doctest: +ELLIPSIS 0 1 2 ... 9 ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=2) ok Trying: def f(x): r''' Should fail (option directive not on the last line): >>> for x in range(10): # doctest: +ELLIPSIS ... print(x, end=' ') # doctest: +NORMALIZE_WHITESPACE 0 1 2...9 ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=1) ok Trying: s = '>>> print(12) #doctest: +BADOPTION' Expecting nothing ok Trying: test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) Expecting: Traceback (most recent call last): ValueError: line 1 of the doctest for s has an invalid option: '+BADOPTION' ok Trying: s = '>>> print(12) #doctest: ELLIPSIS' Expecting nothing ok Trying: test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) Expecting: Traceback (most recent call last): ValueError: line 1 of the doctest for s has an invalid option: 'ELLIPSIS' ok Trying: s = '>>> # doctest: +ELLIPSIS' Expecting nothing ok Trying: test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) Expecting: Traceback (most recent call last): ValueError: line 0 of the doctest for s has an option directive on a line with no example: '# doctest: +ELLIPSIS' ok Trying: def f(x): '>>> True\n1\n' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=1) ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: flags = doctest.DONT_ACCEPT_TRUE_FOR_1 Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 2, in f Failed example: True Expected: 1 Got: True TestResults(failed=1, attempted=1) ok Trying: def f(x): '>>> print("a\\n\\nb")\na\n\nb\n' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) Expecting: TestResults(failed=0, attempted=1) ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: flags = doctest.DONT_ACCEPT_BLANKLINE Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 2, in f Failed example: print("a\n\nb") Expected: a b Got: a b TestResults(failed=1, attempted=1) ok Trying: def f(x): '>>> print(1, 2, 3)\n 1 2\n 3' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 2, in f Failed example: print(1, 2, 3) Expected: 1 2 3 Got: 1 2 3 TestResults(failed=1, attempted=1) ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: flags = doctest.NORMALIZE_WHITESPACE Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) Expecting: TestResults(failed=0, attempted=1) ok Trying: print(list(range(20))) #doctest: +NORMALIZE_WHITESPACE Expecting: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] ok Trying: def f(x): '>>> print(list(range(15)))\n[0, 1, 2, ..., 14]\n' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 2, in f Failed example: print(list(range(15))) Expected: [0, 1, 2, ..., 14] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] TestResults(failed=1, attempted=1) ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: flags = doctest.ELLIPSIS Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) Expecting: TestResults(failed=0, attempted=1) ok Trying: if 1: for i in range(100): print(i**2, end=' ') #doctest: +ELLIPSIS print('!') Expecting: 0 1...4...9 16 ... 36 49 64 ... 9801 ! ok Trying: if 1: #doctest: +ELLIPSIS for i in range(20): print(i, end=' ') print(20) Expecting: 0 1 2 ...1...2...0 ok Trying: print(list(range(20))) # doctest:+ELLIPSIS Expecting: [0, 1, ..., 18, 19] ok Trying: print(list(range(20))) # doctest: +ELLIPSIS # doctest: +NORMALIZE_WHITESPACE Expecting: [0, 1, ..., 18, 19] ok Trying: import random Expecting nothing ok Trying: def f(x): r''' >>> print('\n'.join('abcdefg')) a B c d f g h ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 3, in f Failed example: print('\n'.join('abcdefg')) Expected: a B c d f g h Got: a b c d e f g TestResults(failed=1, attempted=1) ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: flags = doctest.REPORT_UDIFF Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 3, in f Failed example: print('\n'.join('abcdefg')) Differences (unified diff with -expected +actual): @@ -1,7 +1,7 @@ a -B +b c d +e f g -h TestResults(failed=1, attempted=1) ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: flags = doctest.REPORT_CDIFF Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 3, in f Failed example: print('\n'.join('abcdefg')) Differences (context diff with expected followed by actual): *************** *** 1,7 **** a ! B c d f g - h --- 1,7 ---- a ! b c d + e f g TestResults(failed=1, attempted=1) ok Trying: def f(x): r''' >>> print("a b c d e f g h i j k l m") a b c d e f g h i j k 1 m ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: flags = doctest.REPORT_NDIFF Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 3, in f Failed example: print("a b c d e f g h i j k l m") Differences (ndiff with -expected +actual): - a b c d e f g h i j k 1 m ? ^ + a b c d e f g h i j k l m ? + ++ ^ TestResults(failed=1, attempted=1) ok Trying: def f(x): r''' >>> print(1) # first success 1 >>> print(2) # first failure 200 >>> print(3) # second failure 300 >>> print(4) # second success 4 >>> print(5) # third failure 500 ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: flags = doctest.REPORT_ONLY_FIRST_FAILURE Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 5, in f Failed example: print(2) # first failure Expected: 200 Got: 2 TestResults(failed=3, attempted=5) ok Trying: doctest.DocTestRunner(verbose=True, optionflags=flags).run(test) # doctest: +ELLIPSIS Expecting: Trying: print(1) # first success Expecting: 1 ok Trying: print(2) # first failure Expecting: 200 ********************************************************************** File ..., line 5, in f Failed example: print(2) # first failure Expected: 200 Got: 2 TestResults(failed=3, attempted=5) ok Trying: flags = doctest.FAIL_FAST Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 5, in f Failed example: print(2) # first failure Expected: 200 Got: 2 TestResults(failed=1, attempted=2) ok Trying: flags = doctest.FAIL_FAST | doctest.REPORT_ONLY_FIRST_FAILURE Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 5, in f Failed example: print(2) # first failure Expected: 200 Got: 2 TestResults(failed=1, attempted=2) ok Trying: def f(x): r''' >>> print(1) # first success 1 >>> raise ValueError(2) # first failure 200 >>> print(3) # second failure 300 >>> print(4) # second success 4 >>> print(5) # third failure 500 ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: flags = doctest.REPORT_ONLY_FIRST_FAILURE Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 5, in f Failed example: raise ValueError(2) # first failure Exception raised: ... ValueError: 2 TestResults(failed=3, attempted=5) ok Trying: flags = doctest.FAIL_FAST Expecting nothing ok Trying: doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File ..., line 5, in f Failed example: raise ValueError(2) # first failure Exception raised: ... ValueError: 2 TestResults(failed=1, attempted=2) ok Trying: unlikely = "UNLIKELY_OPTION_NAME" Expecting nothing ok Trying: unlikely in doctest.OPTIONFLAGS_BY_NAME Expecting: False ok Trying: new_flag_value = doctest.register_optionflag(unlikely) Expecting nothing ok Trying: unlikely in doctest.OPTIONFLAGS_BY_NAME Expecting: True ok Trying: redundant_flag_value = doctest.register_optionflag(unlikely) Expecting nothing ok Trying: redundant_flag_value == new_flag_value Expecting: True ok Trying: del doctest.OPTIONFLAGS_BY_NAME[unlikely] Expecting nothing ok Trying: def f(x): ''' >>> x = 12 >>> print(x) 12 >>> x//2 6 ''' Expecting nothing ok Trying: test = doctest.DocTestFinder().find(f)[0] Expecting nothing ok Trying: doctest.DocTestRunner(verbose=True).run(test) Expecting: Trying: x = 12 Expecting nothing ok Trying: print(x) Expecting: 12 ok Trying: x//2 Expecting: 6 ok TestResults(failed=0, attempted=3) ok Trying: old_argv = sys.argv Expecting nothing ok Trying: sys.argv = ['test'] Expecting nothing ok Trying: doctest.DocTestRunner().run(test) Expecting: TestResults(failed=0, attempted=3) ok Trying: sys.argv = ['test', '-v'] Expecting nothing ok Trying: doctest.DocTestRunner().run(test) Expecting: Trying: x = 12 Expecting nothing ok Trying: print(x) Expecting: 12 ok Trying: x//2 Expecting: 6 ok TestResults(failed=0, attempted=3) ok Trying: sys.argv = old_argv Expecting nothing ok Trying: import unittest Expecting nothing ok Trying: import test.sample_doctest Expecting nothing ok Trying: suite = doctest.DocTestSuite(test.sample_doctest) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: suite = doctest.DocTestSuite('test.sample_doctest') Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: suite = doctest.DocTestSuite('test.sample_doctest_no_doctests') Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: suite = doctest.DocTestSuite('test.sample_doctest_no_docstrings') Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: suite = test.sample_doctest.test_suite() Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: finder = doctest.DocTestFinder() Expecting nothing ok Trying: suite = doctest.DocTestSuite('test.sample_doctest', test_finder=finder) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: finder = doctest.DocTestFinder() Expecting nothing ok Trying: suite = doctest.DocTestSuite('test.sample_doctest_no_docstrings', test_finder=finder) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: suite = doctest.DocTestSuite('test.sample_doctest', globs={}) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: suite = doctest.DocTestSuite('test.sample_doctest', extraglobs={'y': 1}) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: suite = doctest.DocTestSuite('test.sample_doctest', optionflags=doctest.DONT_ACCEPT_BLANKLINE) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: def setUp(t): import test.test_doctest test.test_doctest.sillySetup = True Expecting nothing ok Trying: def tearDown(t): import test.test_doctest del test.test_doctest.sillySetup Expecting nothing ok Trying: suite = doctest.DocTestSuite('test.sample_doctest', setUp=setUp, tearDown=tearDown) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: import test.test_doctest Expecting nothing ok Trying: test.test_doctest.sillySetup Expecting: Traceback (most recent call last): ... AttributeError: module 'test.test_doctest' has no attribute 'sillySetup' ok Trying: def setUp(test): test.globs['y'] = 1 Expecting nothing ok Trying: suite = doctest.DocTestSuite('test.sample_doctest', setUp=setUp) Expecting nothing ok Trying: suite.run(unittest.TestResult()) Expecting: ok Trying: example = doctest.Example('print(1)', '1\n') Expecting nothing ok Trying: (example.source, example.want, example.exc_msg, example.lineno, example.indent, example.options) Expecting: ('print(1)\n', '1\n', None, 0, 0, {}) ok Trying: exc_msg = 'IndexError: pop from an empty list' Expecting nothing ok Trying: example = doctest.Example('[].pop()', '', exc_msg, lineno=5, indent=4, options={doctest.ELLIPSIS: True}) Expecting nothing ok Trying: (example.source, example.want, example.exc_msg, example.lineno, example.indent, example.options) Expecting: ('[].pop()\n', '', 'IndexError: pop from an empty list\n', 5, 4, {8: True}) ok Trying: e = doctest.Example('print(1)', '1\n') Expecting nothing ok Trying: e.source, e.want Expecting: ('print(1)\n', '1\n') ok Trying: e = doctest.Example('print(1)\n', '1\n') Expecting nothing ok Trying: e.source, e.want Expecting: ('print(1)\n', '1\n') ok Trying: e = doctest.Example('print(1);\nprint(2)\n', '1\n2\n') Expecting nothing ok Trying: e.source, e.want Expecting: ('print(1);\nprint(2)\n', '1\n2\n') ok Trying: e = doctest.Example('print(1);\nprint(2)', '1\n2\n') Expecting nothing ok Trying: e.source, e.want Expecting: ('print(1);\nprint(2)\n', '1\n2\n') ok Trying: e = doctest.Example('', '') Expecting nothing ok Trying: e.source, e.want Expecting: ('\n', '') ok Trying: e = doctest.Example('print(1)', '1\n') Expecting nothing ok Trying: e.source, e.want Expecting: ('print(1)\n', '1\n') ok Trying: e = doctest.Example('print(1)', '1') Expecting nothing ok Trying: e.source, e.want Expecting: ('print(1)\n', '1\n') ok Trying: e = doctest.Example('print', '') Expecting nothing ok Trying: e.source, e.want Expecting: ('print\n', '') ok Trying: exc_msg = 'IndexError: pop from an empty list' Expecting nothing ok Trying: e = doctest.Example('[].pop()', '', exc_msg) Expecting nothing ok Trying: e.exc_msg Expecting: 'IndexError: pop from an empty list\n' ok Trying: exc_msg = 'IndexError: pop from an empty list\n' Expecting nothing ok Trying: e = doctest.Example('[].pop()', '', exc_msg) Expecting nothing ok Trying: e.exc_msg Expecting: 'IndexError: pop from an empty list\n' ok Trying: exc_msg = 'ValueError: 1\n 2' Expecting nothing ok Trying: e = doctest.Example('raise ValueError("1\n 2")', '', exc_msg) Expecting nothing ok Trying: e.exc_msg Expecting: 'ValueError: 1\n 2\n' ok Trying: exc_msg = 'ValueError: 1\n 2\n' Expecting nothing ok Trying: e = doctest.Example('raise ValueError("1\n 2")', '', exc_msg) Expecting nothing ok Trying: e.exc_msg Expecting: 'ValueError: 1\n 2\n' ok Trying: exc_msg = '' Expecting nothing ok Trying: e = doctest.Example('raise X()', '', exc_msg) Expecting nothing ok Trying: e.exc_msg Expecting: '\n' ok Trying: example = doctest.Example('print 1', '1\n') Expecting nothing ok Trying: same_example = doctest.Example('print 1', '1\n') Expecting nothing ok Trying: other_example = doctest.Example('print 42', '42\n') Expecting nothing ok Trying: example == same_example Expecting: True ok Trying: example != same_example Expecting: False ok Trying: hash(example) == hash(same_example) Expecting: True ok Trying: example == other_example Expecting: False ok Trying: example != other_example Expecting: True ok Trying: s = ''' >>> x = 12 >>> print(x) 12 ''' Expecting nothing ok Trying: real_stdin = sys.stdin Expecting nothing ok Trying: sys.stdin = _FakeInput(['next', 'print(x)', 'continue']) Expecting nothing ok Trying: try: doctest.debug_src(s) finally: sys.stdin = real_stdin Expecting: > (1)() (Pdb) next 12 --Return-- > (1)()->None (Pdb) print(x) 12 (Pdb) continue ********************************************************************** File "/dev/shm/gerrit/Python-3.6.0/Lib/test/test_doctest.py", line 1841, in test.test_doctest.test_debug Failed example: try: doctest.debug_src(s) finally: sys.stdin = real_stdin Expected: > (1)() (Pdb) next 12 --Return-- > (1)()->None (Pdb) print(x) 12 (Pdb) continue Got: *** ModuleNotFoundError: No module named 'IPython' > (1)() (Pdb) next 12 --Return-- > (1)()->None (Pdb) print(x) 12 (Pdb) continue Trying: import tempfile, os Expecting nothing ok Trying: fn = tempfile.mktemp() Expecting nothing ok Trying: with open(fn, 'wb') as f: f.write(b'Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n') Expecting: 35 ok Trying: doctest.testfile(fn, module_relative=False, verbose=False) Expecting: TestResults(failed=0, attempted=1) ok Trying: os.remove(fn) Expecting nothing ok Trying: fn = tempfile.mktemp() Expecting nothing ok Trying: with open(fn, 'wb') as f: f.write(b'Test:\n\n >>> x = 1 + 1\n\nDone.\n') Expecting: 30 ok Trying: doctest.testfile(fn, module_relative=False, verbose=False) Expecting: TestResults(failed=0, attempted=1) ok Trying: os.remove(fn) Expecting nothing ok Trying: 'one other test' Expecting: 'one other test' ok Trying: doc = ''' >>> x = 42 >>> raise Exception('clé') Traceback (most recent call last): Exception: clé >>> import pdb; pdb.set_trace() ''' Expecting nothing ok Trying: parser = doctest.DocTestParser() Expecting nothing ok Trying: test = parser.get_doctest(doc, {}, "foo-bar@baz", "foo-bar@baz.py", 0) Expecting nothing ok Trying: runner = doctest.DocTestRunner(verbose=False) Expecting nothing ok Trying: real_stdin = sys.stdin Expecting nothing ok Trying: sys.stdin = _FakeInput([ 'print(x)', # print data defined by the example 'continue', # stop debugging '']) Expecting nothing ok Trying: try: runner.run(test) finally: sys.stdin = real_stdin Expecting: --Return-- > (1)()->None -> import pdb; pdb.set_trace() (Pdb) print(x) 42 (Pdb) continue TestResults(failed=0, attempted=3) ********************************************************************** File "/dev/shm/gerrit/Python-3.6.0/Lib/test/test_doctest.py", line 1885, in test.test_doctest.test_pdb_set_trace Failed example: try: runner.run(test) finally: sys.stdin = real_stdin Expected: --Return-- > (1)()->None -> import pdb; pdb.set_trace() (Pdb) print(x) 42 (Pdb) continue TestResults(failed=0, attempted=3) Got: --Return-- *** ModuleNotFoundError: No module named 'IPython' > (1)()->None -> import pdb; pdb.set_trace() (Pdb) print(x) 42 (Pdb) continue TestResults(failed=0, attempted=3) Trying: def calls_set_trace(): y=2 import pdb; pdb.set_trace() Expecting nothing ok Trying: doc = ''' >>> x=1 >>> calls_set_trace() ''' Expecting nothing ok Trying: test = parser.get_doctest(doc, globals(), "foo-bar@baz", "foo-bar@baz.py", 0) Expecting nothing ok Trying: real_stdin = sys.stdin Expecting nothing ok Trying: sys.stdin = _FakeInput([ 'print(y)', # print data defined in the function 'up', # out of function 'print(x)', # print data defined by the example 'continue', # stop debugging '']) Expecting nothing ok Trying: try: runner.run(test) finally: sys.stdin = real_stdin Expecting: --Return-- > (3)calls_set_trace()->None -> import pdb; pdb.set_trace() (Pdb) print(y) 2 (Pdb) up > (1)() -> calls_set_trace() (Pdb) print(x) 1 (Pdb) continue TestResults(failed=0, attempted=2) ********************************************************************** File "/dev/shm/gerrit/Python-3.6.0/Lib/test/test_doctest.py", line 1914, in test.test_doctest.test_pdb_set_trace Failed example: try: runner.run(test) finally: sys.stdin = real_stdin Expected: --Return-- > (3)calls_set_trace()->None -> import pdb; pdb.set_trace() (Pdb) print(y) 2 (Pdb) up > (1)() -> calls_set_trace() (Pdb) print(x) 1 (Pdb) continue TestResults(failed=0, attempted=2) Got: --Return-- *** ModuleNotFoundError: No module named 'IPython' > (3)calls_set_trace()->None -> import pdb; pdb.set_trace() (Pdb) print(y) 2 (Pdb) up > (1)() -> calls_set_trace() (Pdb) print(x) 1 (Pdb) continue TestResults(failed=0, attempted=2) Trying: doc = ''' >>> def f(x): ... g(x*2) >>> def g(x): ... print(x+3) ... import pdb; pdb.set_trace() >>> f(3) ''' Expecting nothing ok Trying: test = parser.get_doctest(doc, globals(), "foo-bar@baz", "foo-bar@baz.py", 0) Expecting nothing ok Trying: real_stdin = sys.stdin Expecting nothing ok Trying: sys.stdin = _FakeInput([ 'list', # list source from example 2 'next', # return from g() 'list', # list source from example 1 'next', # return from f() 'list', # list source from example 3 'continue', # stop debugging '']) Expecting nothing ok Trying: try: runner.run(test) finally: sys.stdin = real_stdin # doctest: +NORMALIZE_WHITESPACE Expecting: --Return-- > (3)g()->None -> import pdb; pdb.set_trace() (Pdb) list 1 def g(x): 2 print(x+3) 3 -> import pdb; pdb.set_trace() [EOF] (Pdb) next --Return-- > (2)f()->None -> g(x*2) (Pdb) list 1 def f(x): 2 -> g(x*2) [EOF] (Pdb) next --Return-- > (1)()->None -> f(3) (Pdb) list 1 -> f(3) [EOF] (Pdb) continue ********************************************************************** File "foo-bar@baz.py", line 7, in foo-bar@baz Failed example: f(3) Expected nothing Got: 9 TestResults(failed=1, attempted=3) ********************************************************************** File "/dev/shm/gerrit/Python-3.6.0/Lib/test/test_doctest.py", line 1952, in test.test_doctest.test_pdb_set_trace Failed example: try: runner.run(test) finally: sys.stdin = real_stdin # doctest: +NORMALIZE_WHITESPACE Expected: --Return-- > (3)g()->None -> import pdb; pdb.set_trace() (Pdb) list 1 def g(x): 2 print(x+3) 3 -> import pdb; pdb.set_trace() [EOF] (Pdb) next --Return-- > (2)f()->None -> g(x*2) (Pdb) list 1 def f(x): 2 -> g(x*2) [EOF] (Pdb) next --Return-- > (1)()->None -> f(3) (Pdb) list 1 -> f(3) [EOF] (Pdb) continue ********************************************************************** File "foo-bar@baz.py", line 7, in foo-bar@baz Failed example: f(3) Expected nothing Got: 9 TestResults(failed=1, attempted=3) Got: --Return-- *** ModuleNotFoundError: No module named 'IPython' > (3)g()->None -> import pdb; pdb.set_trace() (Pdb) list 1 def g(x): 2 print(x+3) 3 -> import pdb; pdb.set_trace() [EOF] (Pdb) next --Return-- > (2)f()->None -> g(x*2) (Pdb) list 1 def f(x): 2 -> g(x*2) [EOF] (Pdb) next --Return-- > (1)()->None -> f(3) (Pdb) list 1 -> f(3) [EOF] (Pdb) continue ********************************************************************** File "foo-bar@baz.py", line 7, in foo-bar@baz Failed example: f(3) Expected nothing Got: 9 TestResults(failed=1, attempted=3) Trying: class C(object): def calls_set_trace(self): y = 1 import pdb; pdb.set_trace() self.f1() y = 2 def f1(self): x = 1 self.f2() x = 2 def f2(self): z = 1 z = 2 Expecting nothing ok Trying: calls_set_trace = C().calls_set_trace Expecting nothing ok Trying: doc = ''' >>> a = 1 >>> calls_set_trace() ''' Expecting nothing ok Trying: parser = doctest.DocTestParser() Expecting nothing ok Trying: runner = doctest.DocTestRunner(verbose=False) Expecting nothing ok Trying: test = parser.get_doctest(doc, globals(), "foo-bar@baz", "foo-bar@baz.py", 0) Expecting nothing ok Trying: real_stdin = sys.stdin Expecting nothing ok Trying: sys.stdin = _FakeInput([ 'print(y)', # print data defined in the function 'step', 'step', 'step', 'step', 'step', 'step', 'print(z)', 'up', 'print(x)', 'up', 'print(y)', 'up', 'print(foo)', 'continue', # stop debugging '']) Expecting nothing ok Trying: try: runner.run(test) finally: sys.stdin = real_stdin # doctest: +REPORT_NDIFF Expecting: > (5)calls_set_trace() -> self.f1() (Pdb) print(y) 1 (Pdb) step --Call-- > (7)f1() -> def f1(self): (Pdb) step > (8)f1() -> x = 1 (Pdb) step > (9)f1() -> self.f2() (Pdb) step --Call-- > (11)f2() -> def f2(self): (Pdb) step > (12)f2() -> z = 1 (Pdb) step > (13)f2() -> z = 2 (Pdb) print(z) 1 (Pdb) up > (9)f1() -> self.f2() (Pdb) print(x) 1 (Pdb) up > (5)calls_set_trace() -> self.f1() (Pdb) print(y) 1 (Pdb) up > (1)() -> calls_set_trace() (Pdb) print(foo) *** NameError: name 'foo' is not defined (Pdb) continue TestResults(failed=0, attempted=2) ********************************************************************** File "/dev/shm/gerrit/Python-3.6.0/Lib/test/test_doctest.py", line 2025, in test.test_doctest.test_pdb_set_trace_nested Failed example: try: runner.run(test) finally: sys.stdin = real_stdin # doctest: +REPORT_NDIFF Differences (ndiff with -expected +actual): + *** ModuleNotFoundError: No module named 'IPython' > (5)calls_set_trace() -> self.f1() (Pdb) print(y) 1 (Pdb) step --Call-- > (7)f1() -> def f1(self): (Pdb) step > (8)f1() -> x = 1 (Pdb) step > (9)f1() -> self.f2() (Pdb) step --Call-- > (11)f2() -> def f2(self): (Pdb) step > (12)f2() -> z = 1 (Pdb) step > (13)f2() -> z = 2 (Pdb) print(z) 1 (Pdb) up > (9)f1() -> self.f2() (Pdb) print(x) 1 (Pdb) up > (5)calls_set_trace() -> self.f1() (Pdb) print(y) 1 (Pdb) up > (1)() -> calls_set_trace() (Pdb) print(foo) *** NameError: name 'foo' is not defined (Pdb) continue TestResults(failed=0, attempted=2) Trying: save_argv = sys.argv Expecting nothing ok Trying: if '-v' in sys.argv: sys.argv = [arg for arg in save_argv if arg != '-v'] Expecting nothing ok Trying: doctest.testfile('test_doctest.txt') # doctest: +ELLIPSIS Expecting: ********************************************************************** File "...", line 6, in test_doctest.txt Failed example: favorite_color Exception raised: ... NameError: name 'favorite_color' is not defined ********************************************************************** 1 items had failures: 1 of 2 in test_doctest.txt ***Test Failed*** 1 failures. TestResults(failed=1, attempted=2) ok Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: globs = {'favorite_color': 'blue'} Expecting nothing ok Trying: doctest.testfile('test_doctest.txt', globs=globs) Expecting: TestResults(failed=0, attempted=2) ok Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: extraglobs = {'favorite_color': 'red'} Expecting nothing ok Trying: doctest.testfile('test_doctest.txt', globs=globs, extraglobs=extraglobs) # doctest: +ELLIPSIS Expecting: ********************************************************************** File "...", line 6, in test_doctest.txt Failed example: favorite_color Expected: 'blue' Got: 'red' ********************************************************************** 1 items had failures: 1 of 2 in test_doctest.txt ***Test Failed*** 1 failures. TestResults(failed=1, attempted=2) ok Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: doctest.testfile('test_doctest.txt', globs=globs, module_relative='test') Expecting: TestResults(failed=0, attempted=2) ok Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: doctest.testfile('test_doctest.txt', globs=globs, verbose=True) Expecting: Trying: favorite_color Expecting: 'blue' ok Trying: if 1: print('a') print() print('b') Expecting: a b ok 1 items passed all tests: 2 tests in test_doctest.txt 2 tests in 1 items. 2 passed and 0 failed. Test passed. TestResults(failed=0, attempted=2) ok Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: doctest.testfile('test_doctest.txt', name='newname') # doctest: +ELLIPSIS Expecting: ********************************************************************** File "...", line 6, in newname ... TestResults(failed=1, attempted=2) ok Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: doctest.testfile('test_doctest.txt', report=False) # doctest: +ELLIPSIS Expecting: ********************************************************************** File "...", line 6, in test_doctest.txt Failed example: favorite_color Exception raised: ... NameError: name 'favorite_color' is not defined TestResults(failed=1, attempted=2) ok Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: doctest.testfile('test_doctest.txt', raise_on_error=True) # doctest: +ELLIPSIS Expecting: Traceback (most recent call last): doctest.UnexpectedException: ... ok Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: doctest.testfile('test_doctest4.txt', encoding='latin-1') # doctest: +ELLIPSIS Expecting: ********************************************************************** File "...", line 7, in test_doctest4.txt Failed example: '...' Expected: 'f\xf6\xf6' Got: 'f\xc3\xb6\xc3\xb6' ********************************************************************** ... ********************************************************************** 1 items had failures: 2 of 2 in test_doctest4.txt ***Test Failed*** 2 failures. TestResults(failed=2, attempted=2) ok Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: doctest.testfile('test_doctest4.txt', encoding='utf-8') Expecting: TestResults(failed=0, attempted=2) ok Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: doctest.testfile('test_doctest4.txt', encoding='utf-8', verbose=True) Expecting: Trying: 'föö' Expecting: 'f\xf6\xf6' ok Trying: 'bąr' Expecting: 'b\u0105r' ok 1 items passed all tests: 2 tests in test_doctest4.txt 2 tests in 1 items. 2 passed and 0 failed. Test passed. TestResults(failed=0, attempted=2) ok Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: sys.argv = save_argv Expecting nothing ok Trying: import unicodedata Expecting nothing ok Trying: doctest.testmod(unicodedata, verbose=False) Expecting: TestResults(failed=0, attempted=0) ok Trying: import test.test_doctest Expecting nothing ok Trying: name = 'test.test_doctest.sample_func' Expecting nothing ok Trying: print(doctest.testsource(test.test_doctest, name)) Expecting: # Blah blah # print(sample_func(22)) # Expected: ## 44 # # Yee ha! ok Trying: name = 'test.test_doctest.SampleNewStyleClass' Expecting nothing ok Trying: print(doctest.testsource(test.test_doctest, name)) Expecting: print('1\n2\n3') # Expected: ## 1 ## 2 ## 3 ok Trying: name = 'test.test_doctest.SampleClass.a_classmethod' Expecting nothing ok Trying: print(doctest.testsource(test.test_doctest, name)) Expecting: print(SampleClass.a_classmethod(10)) # Expected: ## 12 print(SampleClass(0).a_classmethod(10)) # Expected: ## 12 ok Trying: x, y = 'foo', '' Expecting nothing ok Trying: print(x, y) Expecting: foo ok Trying: doc = ''' >>> raise Exception('clé') ''' Expecting nothing ok Trying: parser = doctest.DocTestParser() Expecting nothing ok Trying: test = parser.get_doctest(doc, {}, "foo-bär@baz", "foo-bär@baz.py", 0) Expecting nothing ok Trying: test Expecting: ok Trying: runner = doctest.DocTestRunner(verbose=False) Expecting nothing ok Trying: runner.run(test) # doctest: +ELLIPSIS Expecting: ********************************************************************** File "foo-bär@baz.py", line 2, in foo-bär@baz Failed example: raise Exception('clé') Exception raised: Traceback (most recent call last): File ... compileflags, 1), test.globs) File "", line 1, in raise Exception('clé') Exception: clé TestResults(failed=1, attempted=1) ok Trying: suite = doctest.DocFileSuite('test_doctest.txt', optionflags=doctest.DONT_ACCEPT_BLANKLINE) Expecting nothing ok Trying: import unittest Expecting nothing ok Trying: result = suite.run(unittest.TestResult()) Expecting nothing ok Trying: print(result.failures[0][1]) # doctest: +ELLIPSIS Expecting: Traceback ... Failed example: favorite_color ... Failed example: if 1: ... ok Trying: old = doctest.set_unittest_reportflags( doctest.REPORT_ONLY_FIRST_FAILURE) Expecting nothing ok Trying: result = suite.run(unittest.TestResult()) Expecting nothing ok Trying: print(result.failures[0][1]) # doctest: +ELLIPSIS Expecting: Traceback ... Failed example: favorite_color Exception raised: ... NameError: name 'favorite_color' is not defined ok Trying: suite = doctest.DocFileSuite('test_doctest.txt', optionflags=doctest.DONT_ACCEPT_BLANKLINE | doctest.REPORT_NDIFF) Expecting nothing ok Trying: result = suite.run(unittest.TestResult()) Expecting nothing ok Trying: print(result.failures[0][1]) # doctest: +ELLIPSIS Expecting: Traceback ... Failed example: favorite_color ... Failed example: if 1: print('a') print() print('b') Differences (ndiff with -expected +actual): a - + b ok Trying: ignored = doctest.set_unittest_reportflags(old) Expecting nothing ok 13 items had no tests: test.test_doctest test.test_doctest.SampleClass.NestedClass.get test.test_doctest.SampleClass.NestedClass.square test.test_doctest.Wrapper test.test_doctest.Wrapper.__call__ test.test_doctest.Wrapper.__init__ test.test_doctest._FakeInput test.test_doctest._FakeInput.__init__ test.test_doctest._FakeInput.readline test.test_doctest.test_DocTestFinder test.test_doctest.test_DocTestRunner test.test_doctest.test_coverage test.test_doctest.test_main 36 items passed all tests: 3 tests in test.test_doctest.SampleClass 3 tests in test.test_doctest.SampleClass.NestedClass 1 tests in test.test_doctest.SampleClass.NestedClass.__init__ 1 tests in test.test_doctest.SampleClass.__init__ 2 tests in test.test_doctest.SampleClass.a_classmethod 1 tests in test.test_doctest.SampleClass.a_property 1 tests in test.test_doctest.SampleClass.a_staticmethod 1 tests in test.test_doctest.SampleClass.double 1 tests in test.test_doctest.SampleClass.get 1 tests in test.test_doctest.SampleNewStyleClass 1 tests in test.test_doctest.SampleNewStyleClass.__init__ 1 tests in test.test_doctest.SampleNewStyleClass.double 1 tests in test.test_doctest.SampleNewStyleClass.get 1 tests in test.test_doctest.sample_func 22 tests in test.test_doctest.test_CLI 40 tests in test.test_doctest.test_DocFileSuite 39 tests in test.test_doctest.test_DocTest 46 tests in test.test_doctest.test_DocTestFinder.basics 6 tests in test.test_doctest.test_DocTestFinder.non_Python_modules 7 tests in test.test_doctest.test_DocTestParser 6 tests in test.test_doctest.test_DocTestRunner.basics 11 tests in test.test_doctest.test_DocTestRunner.displayhook 39 tests in test.test_doctest.test_DocTestRunner.exceptions 33 tests in test.test_doctest.test_DocTestRunner.option_directives 65 tests in test.test_doctest.test_DocTestRunner.optionflags 9 tests in test.test_doctest.test_DocTestRunner.verbose_flag 33 tests in test.test_doctest.test_DocTestSuite 44 tests in test.test_doctest.test_Example 9 tests in test.test_doctest.test_lineendings 1 tests in test.test_doctest.test_look_in_unwrapped 27 tests in test.test_doctest.test_testfile 2 tests in test.test_doctest.test_testmod 7 tests in test.test_doctest.test_testsource 2 tests in test.test_doctest.test_trailing_space_in_test 6 tests in test.test_doctest.test_unicode 11 tests in test.test_doctest.test_unittest_reportflags ********************************************************************** 3 items had failures: 1 of 4 in test.test_doctest.test_debug 3 of 18 in test.test_doctest.test_pdb_set_trace 1 of 9 in test.test_doctest.test_pdb_set_trace_nested 515 tests in 52 items. 510 passed and 5 failed. ***Test Failed*** 5 failures. test_doctest failed 1 test failed: test_doctest Total duration: 2 sec Tests result: FAILURE