mirror of https://github.com/python/cpython.git
Changed doctest to run tests in alphabetic order of name.
This makes verbose-mode output easier to dig thru, and removes an accidental dependence on the order of dict.items() (made visible by recent changes to dictobject.c).
This commit is contained in:
parent
c392b570db
commit
24a4191160
|
@ -813,7 +813,12 @@ def rundict(self, d, name):
|
|||
raise TypeError("Tester.rundict: d must support .items(); " +
|
||||
`d`)
|
||||
f = t = 0
|
||||
for thisname, value in d.items():
|
||||
# Run the tests by alpha order of names, for consistency in
|
||||
# verbose-mode output.
|
||||
names = d.keys()
|
||||
names.sort()
|
||||
for thisname in names:
|
||||
value = d[thisname]
|
||||
if type(value) in (_FunctionType, _ClassType):
|
||||
f2, t2 = self.__runone(value, name + "." + thisname)
|
||||
f = f + f2
|
||||
|
@ -832,7 +837,12 @@ def run__test__(self, d, name):
|
|||
savepvt = self.isprivate
|
||||
try:
|
||||
self.isprivate = lambda *args: 0
|
||||
for k, v in d.items():
|
||||
# Run the tests by alpha order of names, for consistency in
|
||||
# verbose-mode output.
|
||||
keys = d.keys()
|
||||
keys.sort()
|
||||
for k in keys:
|
||||
v = d[k]
|
||||
thisname = prefix + k
|
||||
if type(v) is _StringType:
|
||||
f, t = self.runstring(v, thisname)
|
||||
|
|
|
@ -156,6 +156,14 @@ Trying: s.find_longest_match(0, 2, 0, 1)
|
|||
Expecting: (0, 0, 0)
|
||||
ok
|
||||
0 of 6 examples failed in difflib.SequenceMatcher.find_longest_match.__doc__
|
||||
Running difflib.SequenceMatcher.get_matching_blocks.__doc__
|
||||
Trying: s = SequenceMatcher(None, "abxcd", "abcd")
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.get_matching_blocks()
|
||||
Expecting: [(0, 0, 2), (3, 2, 2), (5, 4, 0)]
|
||||
ok
|
||||
0 of 2 examples failed in difflib.SequenceMatcher.get_matching_blocks.__doc__
|
||||
Running difflib.SequenceMatcher.get_opcodes.__doc__
|
||||
Trying: a = "qabxcd"
|
||||
Expecting: nothing
|
||||
|
@ -180,55 +188,6 @@ ok
|
|||
0 of 4 examples failed in difflib.SequenceMatcher.get_opcodes.__doc__
|
||||
Running difflib.SequenceMatcher.quick_ratio.__doc__
|
||||
0 of 0 examples failed in difflib.SequenceMatcher.quick_ratio.__doc__
|
||||
Running difflib.SequenceMatcher.set_seqs.__doc__
|
||||
Trying: s = SequenceMatcher()
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.set_seqs("abcd", "bcde")
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.ratio()
|
||||
Expecting: 0.75
|
||||
ok
|
||||
0 of 3 examples failed in difflib.SequenceMatcher.set_seqs.__doc__
|
||||
Running difflib.SequenceMatcher.set_seq2.__doc__
|
||||
Trying: s = SequenceMatcher(None, "abcd", "bcde")
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.ratio()
|
||||
Expecting: 0.75
|
||||
ok
|
||||
Trying: s.set_seq2("abcd")
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.ratio()
|
||||
Expecting: 1.0
|
||||
ok
|
||||
0 of 4 examples failed in difflib.SequenceMatcher.set_seq2.__doc__
|
||||
Running difflib.SequenceMatcher.set_seq1.__doc__
|
||||
Trying: s = SequenceMatcher(None, "abcd", "bcde")
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.ratio()
|
||||
Expecting: 0.75
|
||||
ok
|
||||
Trying: s.set_seq1("bcde")
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.ratio()
|
||||
Expecting: 1.0
|
||||
ok
|
||||
0 of 4 examples failed in difflib.SequenceMatcher.set_seq1.__doc__
|
||||
Running difflib.SequenceMatcher.get_matching_blocks.__doc__
|
||||
Trying: s = SequenceMatcher(None, "abxcd", "abcd")
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.get_matching_blocks()
|
||||
Expecting: [(0, 0, 2), (3, 2, 2), (5, 4, 0)]
|
||||
ok
|
||||
0 of 2 examples failed in difflib.SequenceMatcher.get_matching_blocks.__doc__
|
||||
Running difflib.SequenceMatcher.real_quick_ratio.__doc__
|
||||
0 of 0 examples failed in difflib.SequenceMatcher.real_quick_ratio.__doc__
|
||||
Running difflib.SequenceMatcher.ratio.__doc__
|
||||
Trying: s = SequenceMatcher(None, "abcd", "bcde")
|
||||
Expecting: nothing
|
||||
|
@ -243,6 +202,47 @@ Trying: s.real_quick_ratio()
|
|||
Expecting: 1.0
|
||||
ok
|
||||
0 of 4 examples failed in difflib.SequenceMatcher.ratio.__doc__
|
||||
Running difflib.SequenceMatcher.real_quick_ratio.__doc__
|
||||
0 of 0 examples failed in difflib.SequenceMatcher.real_quick_ratio.__doc__
|
||||
Running difflib.SequenceMatcher.set_seq1.__doc__
|
||||
Trying: s = SequenceMatcher(None, "abcd", "bcde")
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.ratio()
|
||||
Expecting: 0.75
|
||||
ok
|
||||
Trying: s.set_seq1("bcde")
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.ratio()
|
||||
Expecting: 1.0
|
||||
ok
|
||||
0 of 4 examples failed in difflib.SequenceMatcher.set_seq1.__doc__
|
||||
Running difflib.SequenceMatcher.set_seq2.__doc__
|
||||
Trying: s = SequenceMatcher(None, "abcd", "bcde")
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.ratio()
|
||||
Expecting: 0.75
|
||||
ok
|
||||
Trying: s.set_seq2("abcd")
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.ratio()
|
||||
Expecting: 1.0
|
||||
ok
|
||||
0 of 4 examples failed in difflib.SequenceMatcher.set_seq2.__doc__
|
||||
Running difflib.SequenceMatcher.set_seqs.__doc__
|
||||
Trying: s = SequenceMatcher()
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.set_seqs("abcd", "bcde")
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: s.ratio()
|
||||
Expecting: 0.75
|
||||
ok
|
||||
0 of 3 examples failed in difflib.SequenceMatcher.set_seqs.__doc__
|
||||
Running difflib.get_close_matches.__doc__
|
||||
Trying: get_close_matches("appel", ["ape", "apple", "peach", "puppy"])
|
||||
Expecting: ['apple', 'ape']
|
||||
|
|
|
@ -88,65 +88,6 @@ ok
|
|||
0 of 6 examples failed in doctest.Tester.__doc__
|
||||
Running doctest.Tester.__init__.__doc__
|
||||
0 of 0 examples failed in doctest.Tester.__init__.__doc__
|
||||
Running doctest.Tester.run__test__.__doc__
|
||||
0 of 0 examples failed in doctest.Tester.run__test__.__doc__
|
||||
Running doctest.Tester.runstring.__doc__
|
||||
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
|
||||
(0, 2)
|
||||
ok
|
||||
0 of 3 examples failed in doctest.Tester.runstring.__doc__
|
||||
Running doctest.Tester.summarize.__doc__
|
||||
0 of 0 examples failed in doctest.Tester.summarize.__doc__
|
||||
Running doctest.Tester.rundict.__doc__
|
||||
Trying:
|
||||
def _f():
|
||||
'''>>> assert 1 == 1
|
||||
'''
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying:
|
||||
def g():
|
||||
'''>>> assert 2 != 1
|
||||
'''
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: d = {"_f": _f, "g": g}
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: t = Tester(globs={}, verbose=0)
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: t.rundict(d, "rundict_test") # _f is skipped
|
||||
Expecting: (0, 1)
|
||||
ok
|
||||
Trying: t = Tester(globs={}, verbose=0, isprivate=lambda x,y: 0)
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: t.rundict(d, "rundict_test_pvt") # both are searched
|
||||
Expecting: (0, 2)
|
||||
ok
|
||||
0 of 7 examples failed in doctest.Tester.rundict.__doc__
|
||||
Running doctest.Tester.merge.__doc__
|
||||
Trying: from doctest import Tester
|
||||
Expecting: nothing
|
||||
|
@ -197,6 +138,37 @@ Test passed.
|
|||
(0, 6)
|
||||
ok
|
||||
0 of 10 examples failed in doctest.Tester.merge.__doc__
|
||||
Running doctest.Tester.run__test__.__doc__
|
||||
0 of 0 examples failed in doctest.Tester.run__test__.__doc__
|
||||
Running doctest.Tester.rundict.__doc__
|
||||
Trying:
|
||||
def _f():
|
||||
'''>>> assert 1 == 1
|
||||
'''
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying:
|
||||
def g():
|
||||
'''>>> assert 2 != 1
|
||||
'''
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: d = {"_f": _f, "g": g}
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: t = Tester(globs={}, verbose=0)
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: t.rundict(d, "rundict_test") # _f is skipped
|
||||
Expecting: (0, 1)
|
||||
ok
|
||||
Trying: t = Tester(globs={}, verbose=0, isprivate=lambda x,y: 0)
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: t.rundict(d, "rundict_test_pvt") # both are searched
|
||||
Expecting: (0, 2)
|
||||
ok
|
||||
0 of 7 examples failed in doctest.Tester.rundict.__doc__
|
||||
Running doctest.Tester.rundoc.__doc__
|
||||
Trying: t = Tester(globs={}, verbose=0)
|
||||
Expecting: nothing
|
||||
|
@ -213,6 +185,34 @@ Trying: t.rundoc(_f) # expect 0 failures in 1 example
|
|||
Expecting: (0, 1)
|
||||
ok
|
||||
0 of 3 examples failed in doctest.Tester.rundoc.__doc__
|
||||
Running doctest.Tester.runstring.__doc__
|
||||
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
|
||||
(0, 2)
|
||||
ok
|
||||
0 of 3 examples failed in doctest.Tester.runstring.__doc__
|
||||
Running doctest.Tester.summarize.__doc__
|
||||
0 of 0 examples failed in doctest.Tester.summarize.__doc__
|
||||
Running doctest.is_private.__doc__
|
||||
Trying: is_private("a.b", "my_func")
|
||||
Expecting: 0
|
||||
|
@ -248,14 +248,6 @@ Trying: hex(_TestClass(13).square().get())
|
|||
Expecting: '0xa9'
|
||||
ok
|
||||
0 of 2 examples failed in doctest.__test__._TestClass.__doc__
|
||||
Running doctest.__test__._TestClass.get.__doc__
|
||||
Trying: x = _TestClass(-42)
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: print x.get()
|
||||
Expecting: -42
|
||||
ok
|
||||
0 of 2 examples failed in doctest.__test__._TestClass.get.__doc__
|
||||
Running doctest.__test__._TestClass.__init__.__doc__
|
||||
Trying: t = _TestClass(123)
|
||||
Expecting: nothing
|
||||
|
@ -264,6 +256,14 @@ Trying: print t.get()
|
|||
Expecting: 123
|
||||
ok
|
||||
0 of 2 examples failed in doctest.__test__._TestClass.__init__.__doc__
|
||||
Running doctest.__test__._TestClass.get.__doc__
|
||||
Trying: x = _TestClass(-42)
|
||||
Expecting: nothing
|
||||
ok
|
||||
Trying: print x.get()
|
||||
Expecting: -42
|
||||
ok
|
||||
0 of 2 examples failed in doctest.__test__._TestClass.get.__doc__
|
||||
Running doctest.__test__._TestClass.square.__doc__
|
||||
Trying: _TestClass(13).square().get()
|
||||
Expecting: 169
|
||||
|
|
Loading…
Reference in New Issue