]> granicus.if.org Git - python/commitdiff
DocTestFinder._find(): for tests derived from a module __test__ global,
authorTim Peters <tim.peters@gmail.com>
Mon, 13 Sep 2004 01:07:12 +0000 (01:07 +0000)
committerTim Peters <tim.peters@gmail.com>
Mon, 13 Sep 2004 01:07:12 +0000 (01:07 +0000)
doctest always promised to stick "__test__" in the name.  That got
broken.  Now it's fixed again.

Lib/doctest.py
Lib/test/test_doctest.py
Lib/test/test_generators.py

index 3a8496f4401dce4ec31731e890bc1b6187a6e50f..2aa740853bbf9873a6f0dc48526b08f593d93251 100644 (file)
@@ -1019,7 +1019,7 @@ class DocTestFinder:
                                      "must be strings, functions, methods, "
                                      "classes, or modules: %r" %
                                      (type(val),))
-                valname = '%s.%s' % (name, valname)
+                valname = '%s.__test__.%s' % (name, valname)
                 self._find(tests, val, valname, module, source_lines,
                            globs, seen)
 
index 2b287ed19620f6844ade6982591d7a0d89df8292..d60738bcbbed165ef857c6a6cea7061046e588d7 100644 (file)
@@ -467,8 +467,8 @@ functions, classes, and the `__test__` dictionary, if it exists:
      1  some_module.SampleClass.a_staticmethod
      1  some_module.SampleClass.double
      1  some_module.SampleClass.get
-     1  some_module.c
-     2  some_module.d
+     1  some_module.__test__.c
+     2  some_module.__test__.d
      1  some_module.sample_func
 
 Duplicate Removal
index ca6eebda894c69a728d5515d1a754339475d005c..109af733474282a5a93eaa097e1845f886bed83b 100644 (file)
@@ -654,14 +654,14 @@ syntax_tests = """
 ...     yield 1
 Traceback (most recent call last):
   ..
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.syntax[0]>, line 2)
+SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[0]>, line 2)
 
 >>> def f():
 ...     yield 1
 ...     return 22
 Traceback (most recent call last):
   ..
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.syntax[1]>, line 3)
+SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[1]>, line 3)
 
 "return None" is not the same as "return" in a generator:
 
@@ -670,7 +670,7 @@ SyntaxError: 'return' with argument inside generator (<doctest test.test_generat
 ...     return None
 Traceback (most recent call last):
   ..
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.syntax[2]>, line 3)
+SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[2]>, line 3)
 
 This one is fine:
 
@@ -685,7 +685,7 @@ This one is fine:
 ...         pass
 Traceback (most recent call last):
   ..
-SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (<doctest test.test_generators.syntax[4]>, line 3)
+SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (<doctest test.test_generators.__test__.syntax[4]>, line 3)
 
 >>> def f():
 ...     try:
@@ -699,7 +699,7 @@ SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (<doct
 ...         pass
 Traceback (most recent call last):
   ...
-SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (<doctest test.test_generators.syntax[5]>, line 6)
+SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (<doctest test.test_generators.__test__.syntax[5]>, line 6)
 
 But this is fine:
 
@@ -805,7 +805,7 @@ SyntaxError: invalid syntax
 ...     if 0:
 ...         yield 2             # because it's a generator
 Traceback (most recent call last):
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.syntax[22]>, line 8)
+SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[22]>, line 8)
 
 This one caused a crash (see SF bug 567538):