[Python-checkins] python/dist/src/Lib/test sample_doctest.py, 1.2, 1.3 test_doctest.py, 1.8, 1.9

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Sat Aug 7 07:37:55 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21134/Lib/test

Modified Files:
	sample_doctest.py test_doctest.py 
Log Message:
Bug 772091:  doctest.DocTestSuite does not support __test__

This got fixed "by magic" as part of the refactoring, but wasn't tested
as such.  Now it is.


Index: sample_doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/sample_doctest.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** sample_doctest.py	6 Aug 2004 22:02:59 -0000	1.2
--- sample_doctest.py	7 Aug 2004 05:37:52 -0000	1.3
***************
*** 1,8 ****
  """This is a sample module that doesn't really test anything all that
!    interesting
  
! It simply has a few tests, some of which suceed and some of which fail.
  
! It's important that the numbers remain constance, as another test is
  testing the running of these tests.
  
--- 1,8 ----
  """This is a sample module that doesn't really test anything all that
!    interesting.
  
! It simply has a few tests, some of which succeed and some of which fail.
  
! It's important that the numbers remain constant as another test is
  testing the running of these tests.
  
***************
*** 62,65 ****
--- 62,75 ----
      """
  
+ __test__ = {'good': """
+                     >>> 42
+                     42
+                     """,
+             'bad':  """
+                     >>> 42
+                     666
+                     """,
+            }
+ 
  def test_suite():
      import doctest

Index: test_doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** test_doctest.py	6 Aug 2004 22:02:59 -0000	1.8
--- test_doctest.py	7 Aug 2004 05:37:52 -0000	1.9
***************
*** 987,991 ****
  
  def test_DocTestSuite():
!     """DocTestSuite creates a unittest test suite into a doctest.
  
         We create a Suite by providing a module.  A module can be provided
--- 987,991 ----
  
  def test_DocTestSuite():
!     """DocTestSuite creates a unittest test suite from a doctest.
  
         We create a Suite by providing a module.  A module can be provided
***************
*** 996,1000 ****
           >>> suite = doctest.DocTestSuite(test.sample_doctest)
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=7 errors=0 failures=3>
  
         We can also supply the module by name:
--- 996,1000 ----
           >>> suite = doctest.DocTestSuite(test.sample_doctest)
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=9 errors=0 failures=4>
  
         We can also supply the module by name:
***************
*** 1002,1006 ****
           >>> suite = doctest.DocTestSuite('test.sample_doctest')
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=7 errors=0 failures=3>
  
         We can use the current module:
--- 1002,1006 ----
           >>> suite = doctest.DocTestSuite('test.sample_doctest')
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=9 errors=0 failures=4>
  
         We can use the current module:
***************
*** 1008,1012 ****
           >>> suite = test.sample_doctest.test_suite()
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=7 errors=0 failures=3>
  
         We can supply global variables.  If we pass globs, they will be
--- 1008,1012 ----
           >>> suite = test.sample_doctest.test_suite()
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=9 errors=0 failures=4>
  
         We can supply global variables.  If we pass globs, they will be
***************
*** 1016,1020 ****
           >>> suite = doctest.DocTestSuite('test.sample_doctest', globs={})
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=7 errors=0 failures=4>
  
         Alternatively, we can provide extra globals.  Here we'll make an
--- 1016,1020 ----
           >>> suite = doctest.DocTestSuite('test.sample_doctest', globs={})
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=9 errors=0 failures=5>
  
         Alternatively, we can provide extra globals.  Here we'll make an
***************
*** 1024,1028 ****
           ...                              extraglobs={'y': 1})
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=7 errors=0 failures=2>
  
         You can pass option flags.  Here we'll cause an extra error
--- 1024,1028 ----
           ...                              extraglobs={'y': 1})
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=9 errors=0 failures=3>
  
         You can pass option flags.  Here we'll cause an extra error
***************
*** 1030,1038 ****
  
           >>> suite = doctest.DocTestSuite('test.sample_doctest',
!          ...                         optionflags=doctest.DONT_ACCEPT_BLANKLINE)
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=7 errors=0 failures=4>
  
!        You can supply setUp and teatDoen functions:
  
           >>> def setUp():
--- 1030,1038 ----
  
           >>> suite = doctest.DocTestSuite('test.sample_doctest',
!          ...                      optionflags=doctest.DONT_ACCEPT_BLANKLINE)
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=9 errors=0 failures=5>
  
!        You can supply setUp and tearDown functions:
  
           >>> def setUp():
***************
*** 1049,1053 ****
           ...      setUp=setUp, tearDown=tearDown)
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=7 errors=0 failures=2>
  
         But the tearDown restores sanity:
--- 1049,1053 ----
           ...      setUp=setUp, tearDown=tearDown)
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=9 errors=0 failures=3>
  
         But the tearDown restores sanity:
***************
*** 1060,1064 ****
  
         Finally, you can provide an alternate test finder.  Here we'll
!        use a custom test_finder to to run just the test named bar:
  
           >>> finder = doctest.DocTestFinder(
--- 1060,1068 ----
  
         Finally, you can provide an alternate test finder.  Here we'll
!        use a custom test_finder to to run just the test named bar.
!        However, the test in the module docstring, and the two tests
!        in the module __test__ dict, aren't filtered, so we actually
!        run three tests besides bar's.  The filtering mechanisms are
!        poorly conceived, and will go away someday.
  
           >>> finder = doctest.DocTestFinder(
***************
*** 1067,1072 ****
           ...                              test_finder=finder)
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=2 errors=0 failures=0>
! 
         """
  
--- 1071,1075 ----
           ...                              test_finder=finder)
           >>> suite.run(unittest.TestResult())
!          <unittest.TestResult run=4 errors=0 failures=1>
         """
  



More information about the Python-checkins mailing list