Commit 1c278865 authored by Tim Peters's avatar Tim Peters

Recover from inspect.getmodule() changes. It returns a module for

functions and methods now, including functions defined inside doctests
in test_doctest.py's recursive doctest'ing.
parent cf6bb655
...@@ -387,8 +387,8 @@ an empty test also be created when there's no docstring?) ...@@ -387,8 +387,8 @@ an empty test also be created when there's no docstring?)
>>> def no_examples(v): >>> def no_examples(v):
... ''' no doctest examples ''' ... ''' no doctest examples '''
>>> finder.find(no_examples) >>> finder.find(no_examples) # doctest: +ELLIPSIS
[<DocTest no_examples from None:1 (no examples)>] [<DocTest no_examples from ...:1 (no examples)>]
Finding Tests in Classes Finding Tests in Classes
~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
...@@ -665,6 +665,7 @@ the failure and proceeds to the next example: ...@@ -665,6 +665,7 @@ the failure and proceeds to the next example:
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=True).run(test) >>> doctest.DocTestRunner(verbose=True).run(test)
... # doctest: +ELLIPSIS
Trying: Trying:
x = 12 x = 12
Expecting nothing Expecting nothing
...@@ -674,7 +675,7 @@ the failure and proceeds to the next example: ...@@ -674,7 +675,7 @@ the failure and proceeds to the next example:
Expecting: Expecting:
14 14
********************************************************************** **********************************************************************
Line 3, in f File ..., line 4, in f
Failed example: Failed example:
print x print x
Expected: Expected:
...@@ -790,7 +791,7 @@ unexpected exception: ...@@ -790,7 +791,7 @@ unexpected exception:
>>> doctest.DocTestRunner(verbose=False).run(test) >>> doctest.DocTestRunner(verbose=False).run(test)
... # doctest: +ELLIPSIS ... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 3, in f File ..., line 4, in f
Failed example: Failed example:
print 'pre-exception output', x/0 print 'pre-exception output', x/0
Exception raised: Exception raised:
...@@ -825,7 +826,7 @@ message is raised, then it is reported as a failure: ...@@ -825,7 +826,7 @@ message is raised, then it is reported as a failure:
>>> doctest.DocTestRunner(verbose=False).run(test) >>> doctest.DocTestRunner(verbose=False).run(test)
... # doctest: +ELLIPSIS ... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 2, in f File ..., line 3, in f
Failed example: Failed example:
raise ValueError, 'message' raise ValueError, 'message'
Expected: Expected:
...@@ -862,7 +863,7 @@ But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type: ...@@ -862,7 +863,7 @@ But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type:
>>> doctest.DocTestRunner(verbose=False).run(test) >>> doctest.DocTestRunner(verbose=False).run(test)
... # doctest: +ELLIPSIS ... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 2, in f File ..., line 3, in f
Failed example: Failed example:
raise ValueError, 'message' #doctest: +IGNORE_EXCEPTION_DETAIL raise ValueError, 'message' #doctest: +IGNORE_EXCEPTION_DETAIL
Expected: Expected:
...@@ -886,7 +887,7 @@ unexpected exception: ...@@ -886,7 +887,7 @@ unexpected exception:
>>> doctest.DocTestRunner(verbose=False).run(test) >>> doctest.DocTestRunner(verbose=False).run(test)
... # doctest: +ELLIPSIS ... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 2, in f File ..., line 3, in f
Failed example: Failed example:
1/0 1/0
Exception raised: Exception raised:
...@@ -918,8 +919,9 @@ and 1/0: ...@@ -918,8 +919,9 @@ and 1/0:
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> flags = doctest.DONT_ACCEPT_TRUE_FOR_1 >>> flags = doctest.DONT_ACCEPT_TRUE_FOR_1
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 1, in f File ..., line 2, in f
Failed example: Failed example:
True True
Expected: Expected:
...@@ -943,8 +945,9 @@ and the '<BLANKLINE>' marker: ...@@ -943,8 +945,9 @@ and the '<BLANKLINE>' marker:
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> flags = doctest.DONT_ACCEPT_BLANKLINE >>> flags = doctest.DONT_ACCEPT_BLANKLINE
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 1, in f File ..., line 2, in f
Failed example: Failed example:
print "a\n\nb" print "a\n\nb"
Expected: Expected:
...@@ -966,8 +969,9 @@ treated as equal: ...@@ -966,8 +969,9 @@ treated as equal:
>>> # Without the flag: >>> # Without the flag:
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test) >>> doctest.DocTestRunner(verbose=False).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 1, in f File ..., line 2, in f
Failed example: Failed example:
print 1, 2, 3 print 1, 2, 3
Expected: Expected:
...@@ -997,8 +1001,9 @@ output to match any substring in the actual output: ...@@ -997,8 +1001,9 @@ output to match any substring in the actual output:
>>> # Without the flag: >>> # Without the flag:
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test) >>> doctest.DocTestRunner(verbose=False).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 1, in f File ..., line 2, in f
Failed example: Failed example:
print range(15) print range(15)
Expected: Expected:
...@@ -1052,8 +1057,9 @@ and actual outputs to be displayed using a unified diff: ...@@ -1052,8 +1057,9 @@ and actual outputs to be displayed using a unified diff:
>>> # Without the flag: >>> # Without the flag:
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test) >>> doctest.DocTestRunner(verbose=False).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 2, in f File ..., line 3, in f
Failed example: Failed example:
print '\n'.join('abcdefg') print '\n'.join('abcdefg')
Expected: Expected:
...@@ -1078,8 +1084,9 @@ and actual outputs to be displayed using a unified diff: ...@@ -1078,8 +1084,9 @@ and actual outputs to be displayed using a unified diff:
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> flags = doctest.REPORT_UDIFF >>> flags = doctest.REPORT_UDIFF
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 2, in f File ..., line 3, in f
Failed example: Failed example:
print '\n'.join('abcdefg') print '\n'.join('abcdefg')
Differences (unified diff with -expected +actual): Differences (unified diff with -expected +actual):
...@@ -1102,8 +1109,9 @@ and actual outputs to be displayed using a context diff: ...@@ -1102,8 +1109,9 @@ and actual outputs to be displayed using a context diff:
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> flags = doctest.REPORT_CDIFF >>> flags = doctest.REPORT_CDIFF
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 2, in f File ..., line 3, in f
Failed example: Failed example:
print '\n'.join('abcdefg') print '\n'.join('abcdefg')
Differences (context diff with expected followed by actual): Differences (context diff with expected followed by actual):
...@@ -1139,8 +1147,9 @@ marking, as well as interline differences. ...@@ -1139,8 +1147,9 @@ marking, as well as interline differences.
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> flags = doctest.REPORT_NDIFF >>> flags = doctest.REPORT_NDIFF
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 2, in f File ..., line 3, in f
Failed example: Failed example:
print "a b c d e f g h i j k l m" print "a b c d e f g h i j k l m"
Differences (ndiff with -expected +actual): Differences (ndiff with -expected +actual):
...@@ -1169,8 +1178,9 @@ failing example: ...@@ -1169,8 +1178,9 @@ failing example:
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> flags = doctest.REPORT_ONLY_FIRST_FAILURE >>> flags = doctest.REPORT_ONLY_FIRST_FAILURE
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 4, in f File ..., line 5, in f
Failed example: Failed example:
print 2 # first failure print 2 # first failure
Expected: Expected:
...@@ -1182,6 +1192,7 @@ failing example: ...@@ -1182,6 +1192,7 @@ failing example:
However, output from `report_start` is not supressed: However, output from `report_start` is not supressed:
>>> doctest.DocTestRunner(verbose=True, optionflags=flags).run(test) >>> doctest.DocTestRunner(verbose=True, optionflags=flags).run(test)
... # doctest: +ELLIPSIS
Trying: Trying:
print 1 # first success print 1 # first success
Expecting: Expecting:
...@@ -1192,7 +1203,7 @@ However, output from `report_start` is not supressed: ...@@ -1192,7 +1203,7 @@ However, output from `report_start` is not supressed:
Expecting: Expecting:
200 200
********************************************************************** **********************************************************************
Line 4, in f File ..., line 5, in f
Failed example: Failed example:
print 2 # first failure print 2 # first failure
Expected: Expected:
...@@ -1222,7 +1233,7 @@ count as failures: ...@@ -1222,7 +1233,7 @@ count as failures:
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
... # doctest: +ELLIPSIS ... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 4, in f File ..., line 5, in f
Failed example: Failed example:
raise ValueError(2) # first failure raise ValueError(2) # first failure
Exception raised: Exception raised:
...@@ -1248,8 +1259,9 @@ example with a comment of the form ``# doctest: +OPTION``: ...@@ -1248,8 +1259,9 @@ example with a comment of the form ``# doctest: +OPTION``:
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test) >>> doctest.DocTestRunner(verbose=False).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 2, in f File ..., line 2, in f
Failed example: Failed example:
print range(10) # should fail: no ellipsis print range(10) # should fail: no ellipsis
Expected: Expected:
...@@ -1272,8 +1284,9 @@ comment of the form ``# doctest: -OPTION``: ...@@ -1272,8 +1284,9 @@ comment of the form ``# doctest: -OPTION``:
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False, >>> doctest.DocTestRunner(verbose=False,
... optionflags=doctest.ELLIPSIS).run(test) ... optionflags=doctest.ELLIPSIS).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 6, in f File ..., line 6, in f
Failed example: Failed example:
print range(10) # doctest: -ELLIPSIS print range(10) # doctest: -ELLIPSIS
Expected: Expected:
...@@ -1297,8 +1310,9 @@ do not change the options for surrounding examples: ...@@ -1297,8 +1310,9 @@ do not change the options for surrounding examples:
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test) >>> doctest.DocTestRunner(verbose=False).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 2, in f File ..., line 2, in f
Failed example: Failed example:
print range(10) # Should fail: no ellipsis print range(10) # Should fail: no ellipsis
Expected: Expected:
...@@ -1306,7 +1320,7 @@ do not change the options for surrounding examples: ...@@ -1306,7 +1320,7 @@ do not change the options for surrounding examples:
Got: Got:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
********************************************************************** **********************************************************************
Line 8, in f File ..., line 8, in f
Failed example: Failed example:
print range(10) # Should fail: no ellipsis print range(10) # Should fail: no ellipsis
Expected: Expected:
...@@ -1327,8 +1341,9 @@ may be separated by whitespace, commas, or both: ...@@ -1327,8 +1341,9 @@ may be separated by whitespace, commas, or both:
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test) >>> doctest.DocTestRunner(verbose=False).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 2, in f File ..., line 2, in f
Failed example: Failed example:
print range(10) # Should fail print range(10) # Should fail
Expected: Expected:
...@@ -1346,8 +1361,9 @@ may be separated by whitespace, commas, or both: ...@@ -1346,8 +1361,9 @@ may be separated by whitespace, commas, or both:
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test) >>> doctest.DocTestRunner(verbose=False).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 2, in f File ..., line 2, in f
Failed example: Failed example:
print range(10) # Should fail print range(10) # Should fail
Expected: Expected:
...@@ -1365,8 +1381,9 @@ may be separated by whitespace, commas, or both: ...@@ -1365,8 +1381,9 @@ may be separated by whitespace, commas, or both:
... ''' ... '''
>>> test = doctest.DocTestFinder().find(f)[0] >>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test) >>> doctest.DocTestRunner(verbose=False).run(test)
... # doctest: +ELLIPSIS
********************************************************************** **********************************************************************
Line 2, in f File ..., line 2, in f
Failed example: Failed example:
print range(10) # Should fail print range(10) # Should fail
Expected: Expected:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment