Could not find 'C:\\Program Files\\Python26\\lib\\test' in sys.path to remove it 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, failure: pass 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[0], exc_info[1], exc_info[2] 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, failure: pass 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): ... 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, failure: pass 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[0], exc_info[1], exc_info[2] 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, failure: pass 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 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 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 99 items had no tests: doctest doctest.DebugRunner.report_failure doctest.DebugRunner.report_unexpected_exception doctest.DebugRunner.run doctest.DocFileCase doctest.DocFileCase.__str__ doctest.DocFileCase.format_failure doctest.DocFileCase.id doctest.DocFileSuite doctest.DocFileTest doctest.DocTest doctest.DocTest.__cmp__ doctest.DocTest.__init__ doctest.DocTest.__repr__ doctest.DocTestCase 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.__init__ doctest.OutputChecker doctest.OutputChecker._do_a_fancy_diff doctest.OutputChecker.check_output doctest.OutputChecker.output_difference doctest.TestResults doctest.TestResults.attempted doctest.TestResults.failed doctest.Tester doctest.Tester.__init__ doctest.Tester.merge doctest.Tester.run__test__ doctest.Tester.rundict doctest.Tester.rundoc doctest.Tester.runstring doctest.Tester.summarize doctest.UnexpectedException doctest.UnexpectedException.__init__ doctest.UnexpectedException.__str__ 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._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 114 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(), 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: from doctest import Tester Expecting nothing ok Trying: t = Tester(globs={'x': 42}, verbose=0) Expecting nothing ok Trying: t.runstring(r''' >>> x = x * 2 >>> print x 42 ''', 'XYZ') Expecting: ********************************************************************** Line 3, in XYZ Failed example: print x Expected: 42 Got: 84 TestResults(failed=1, attempted=2) ok Trying: t.runstring(">>> x = x * 2\n>>> print x\n84\n", 'example2') Expecting: TestResults(failed=0, attempted=2) ok Trying: t.summarize() Expecting: ********************************************************************** 1 items had failures: 1 of 2 in XYZ ***Test Failed*** 1 failures. TestResults(failed=1, attempted=4) ok Trying: t.summarize(verbose=1) Expecting: 1 items passed all tests: 2 tests in example2 ********************************************************************** 1 items had failures: 1 of 2 in XYZ 4 tests in 2 items. 3 passed and 1 failed. ***Test Failed*** 1 failures. TestResults(failed=1, attempted=4) ok Trying: from doctest import Tester Expecting nothing ok Trying: t = Tester(globs={}, verbose=1) Expecting nothing ok Trying: test = r''' # just an example >>> x = 1 + 2 >>> x 3 ''' Expecting nothing ok Trying: t.runstring(test, "Example") Expecting: Running string Example Trying: x = 1 + 2 Expecting nothing ok Trying: x Expecting: 3 ok 0 of 2 examples failed in string Example TestResults(failed=0, attempted=2) ok Trying: from doctest import Tester Expecting nothing ok Trying: t = Tester(globs={}, verbose=0) Expecting nothing ok Trying: def _f(): '''Trivial docstring example. >>> assert 2 == 2 ''' return 32 Expecting nothing ok Trying: t.rundoc(_f) # expect 0 failures in 1 example Expecting: TestResults(failed=0, attempted=1) ok Trying: import types Expecting nothing ok Trying: m1 = types.ModuleType('_m1') Expecting nothing ok Trying: m2 = types.ModuleType('_m2') Expecting nothing ok Trying: test_data = """ def _f(): '''>>> assert 1 == 1 ''' def g(): '''>>> assert 2 != 1 ''' class H: '''>>> assert 2 > 1 ''' def bar(self): '''>>> assert 1 < 2 ''' """ Expecting nothing ok Trying: exec test_data in m1.__dict__ Expecting nothing ok Trying: exec test_data in m2.__dict__ Expecting nothing ok Trying: m1.__dict__.update({"f2": m2._f, "g2": m2.g, "h2": m2.H}) Expecting nothing ok Trying: from doctest import Tester Expecting nothing ok Trying: t = Tester(globs={}, verbose=0) Expecting nothing ok Trying: t.rundict(m1.__dict__, "rundict_test", m1) # f2 and g2 and h2 skipped Expecting: TestResults(failed=0, attempted=4) ok Trying: t = Tester(globs={}, verbose=0) Expecting nothing ok Trying: t.rundict(m1.__dict__, "rundict_test_pvt") # None are skipped. Expecting: TestResults(failed=0, attempted=8) ok Trying: doctest.testmod(m1, verbose=False) Expecting: TestResults(failed=0, attempted=4) ok Trying: print sample_func(22) Expecting: 44 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' object 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: 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: 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, 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: 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:', `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: 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''' >>> 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''' >>> 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 range(10) # should fail: no ellipsis [0, 1, ..., 9] >>> print 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 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 range(10) [0, 1, ..., 9] >>> # should fail: no ellipsis >>> print 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 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 range(10) # Should fail: no ellipsis [0, 1, ..., 9] >>> print range(10) # doctest: +ELLIPSIS [0, 1, ..., 9] >>> print 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 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 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 range(10) # Should fail [0, 1, ..., 9] >>> print 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 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 range(10) # Should fail [0, 1, ..., 9] >>> print 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 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 range(10) # Should fail [0, 1, ..., 9] >>> print 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 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 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, 0 1 2 ... 9 >>> for x in range(10): ... print x, # 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, # 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 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 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 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: for i in range(100): print i**2, #doctest: +ELLIPSIS Expecting: 0 1...4...9 16 ... 36 49 64 ... 9801 ok Trying: for i in range(21): #doctest: +ELLIPSIS print i, Expecting: 0 1 2 ...1...2...0 ok Trying: print range(20) # doctest:+ELLIPSIS Expecting: [0, 1, ..., 18, 19] ok Trying: print 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: 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: 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 = test.sample_doctest.test_suite() 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' object 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: s = ''' >>> x = 12 >>> print x 12 ''' Expecting nothing ok Trying: import tempfile 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 ok Trying: doc = ''' >>> x = 42 >>> import pdb; pdb.set_trace() ''' Expecting nothing ok Trying: parser = doctest.DocTestParser() Expecting nothing ok Trying: test = parser.get_doctest(doc, {}, "foo", "foo.py", 0) Expecting nothing ok Trying: runner = doctest.DocTestRunner(verbose=False) Expecting nothing ok Trying: import tempfile 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=2) ok 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", "foo.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) ok 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", "foo.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.py", line 7, in foo Failed example: f(3) Expected nothing Got: 9 TestResults(failed=1, attempted=3) ok 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", "foo.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 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) 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) ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest.py", line 2146, in test.test_doctest.test_testfile Failed example: doctest.testfile('test_doctest.txt') # doctest: +ELLIPSIS Expected: ********************************************************************** 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) Got: Trying: favorite_color Expecting: 'blue' ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest.txt", line 6, in test_doctest.txt Failed example: favorite_color Exception raised: Traceback (most recent call last): File "C:\Program Files\Python26\lib\doctest.py", line 1241, in __run compileflags, 1) in test.globs File "", line 1, in favorite_color NameError: name 'favorite_color' is not defined Trying: if 1: print 'a' print print 'b' Expecting: a b ok ********************************************************************** 1 items had failures: 1 of 2 in test_doctest.txt 2 tests in 1 items. 1 passed and 1 failed. ***Test Failed*** 1 failures. TestResults(failed=1, attempted=2) 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) ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest.py", line 2168, in test.test_doctest.test_testfile Failed example: doctest.testfile('test_doctest.txt', globs=globs) Expected: TestResults(failed=0, attempted=2) Got: 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) 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) ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest.py", line 2173, in test.test_doctest.test_testfile Failed example: doctest.testfile('test_doctest.txt', globs=globs, extraglobs=extraglobs) # doctest: +ELLIPSIS Expected: ********************************************************************** 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) Got: Trying: favorite_color Expecting: 'blue' ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest.txt", line 6, in test_doctest.txt Failed example: favorite_color Expected: 'blue' Got: 'red' Trying: if 1: print 'a' print print 'b' Expecting: a b ok ********************************************************************** 1 items had failures: 1 of 2 in test_doctest.txt 2 tests in 1 items. 1 passed and 1 failed. ***Test Failed*** 1 failures. TestResults(failed=1, attempted=2) 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) ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest.py", line 2193, in test.test_doctest.test_testfile Failed example: doctest.testfile('test_doctest.txt', globs=globs, module_relative='test') Expected: TestResults(failed=0, attempted=2) Got: 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) 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) ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest.py", line 2227, in test.test_doctest.test_testfile Failed example: doctest.testfile('test_doctest.txt', name='newname') # doctest: +ELLIPSIS Expected: ********************************************************************** File "...", line 6, in newname ... TestResults(failed=1, attempted=2) Got: Trying: favorite_color Expecting: 'blue' ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest.txt", line 6, in newname Failed example: favorite_color Exception raised: Traceback (most recent call last): File "C:\Program Files\Python26\lib\doctest.py", line 1241, in __run compileflags, 1) in test.globs File "", line 1, in favorite_color NameError: name 'favorite_color' is not defined Trying: if 1: print 'a' print print 'b' Expecting: a b ok ********************************************************************** 1 items had failures: 1 of 2 in newname 2 tests in 1 items. 1 passed and 1 failed. ***Test Failed*** 1 failures. TestResults(failed=1, attempted=2) 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) ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest.py", line 2238, in test.test_doctest.test_testfile Failed example: doctest.testfile('test_doctest.txt', report=False) # doctest: +ELLIPSIS Expected: ********************************************************************** 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) Got: Trying: favorite_color Expecting: 'blue' ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest.txt", line 6, in test_doctest.txt Failed example: favorite_color Exception raised: Traceback (most recent call last): File "C:\Program Files\Python26\lib\doctest.py", line 1241, in __run compileflags, 1) in test.globs File "", line 1, in favorite_color NameError: name 'favorite_color' is not defined Trying: if 1: print 'a' print print 'b' Expecting: a b ok TestResults(failed=1, attempted=2) 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): UnexpectedException: ... ok Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: doctest.testfile('test_doctest4.txt') # doctest: +ELLIPSIS Expecting: ********************************************************************** File "...", line 7, in test_doctest4.txt Failed example: u'...' Expected: u'f\xf6\xf6' Got: u'f\xc3\xb6\xc3\xb6' ********************************************************************** ... ********************************************************************** 1 items had failures: 2 of 4 in test_doctest4.txt ***Test Failed*** 2 failures. TestResults(failed=2, attempted=4) ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest.py", line 2264, in test.test_doctest.test_testfile Failed example: doctest.testfile('test_doctest4.txt') # doctest: +ELLIPSIS Expected: ********************************************************************** File "...", line 7, in test_doctest4.txt Failed example: u'...' Expected: u'f\xf6\xf6' Got: u'f\xc3\xb6\xc3\xb6' ********************************************************************** ... ********************************************************************** 1 items had failures: 2 of 4 in test_doctest4.txt ***Test Failed*** 2 failures. TestResults(failed=2, attempted=4) Got: Trying: u'föö' Expecting: u'f\xf6\xf6' ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest4.txt", line 7, in test_doctest4.txt Failed example: u'föö' Expected: u'f\xf6\xf6' Got: u'f\xc3\xb6\xc3\xb6' Trying: u'bąr' Expecting: u'b\u0105r' ********************************************************************** File "C:\Program Files\Python26\lib\test\test_doctest4.txt", line 10, in test_doctest4.txt Failed example: u'bąr' Expected: u'b\u0105r' Got: u'b\xc4\x85r' Trying: 'föö' Expecting: 'f\xc3\xb6\xc3\xb6' ok Trying: 'bąr' Expecting: 'b\xc4\x85r' ok ********************************************************************** 1 items had failures: 2 of 4 in test_doctest4.txt 4 tests in 1 items. 2 passed and 2 failed. ***Test Failed*** 2 failures. TestResults(failed=2, attempted=4) Trying: doctest.master = None # Reset master. Expecting nothing ok Trying: doctest.testfile('test_doctest4.txt', encoding='utf-8') Expecting: TestResults(failed=0, attempted=4) test test_doctest crashed -- : 'ascii' codec can't encode characters in position 329-330: ordinal not in range(128) Traceback (most recent call last): File "C:\Program Files\Python26\lib\test\regrtest.py", line 556, in runtest_inner indirect_test() File "C:\Program Files\Python26\lib\test\test_doctest.py", line 2422, in test_main test_support.run_doctest(test_doctest, verbosity=True) File "C:\Program Files\Python26\lib\test\test_support.py", line 750, in run_doctest f, t = doctest.testmod(module, verbose=verbosity) File "C:\Program Files\Python26\lib\doctest.py", line 1830, in testmod runner.run(test) File "C:\Program Files\Python26\lib\doctest.py", line 1374, in run return self.__run(test, compileflags, out) File "C:\Program Files\Python26\lib\doctest.py", line 1290, in __run self.report_failure(out, test, example, got) File "C:\Program Files\Python26\lib\doctest.py", line 1154, in report_failure self._checker.output_difference(example, got, self.optionflags)) UnicodeEncodeError: 'ascii' codec can't encode characters in position 329-330: ordinal not in range(128) 1 test failed: test_doctest