[Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.20, 1.36.2.21

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Fri Aug 6 05:38:21 CEST 2004


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

Modified Files:
      Tag: tim-doctest-branch
	doctest.py 
Log Message:
Spelling, punctuation, parallelism.


Index: doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v
retrieving revision 1.36.2.20
retrieving revision 1.36.2.21
diff -C2 -d -r1.36.2.20 -r1.36.2.21
*** doctest.py	6 Aug 2004 02:13:41 -0000	1.36.2.20
--- doctest.py	6 Aug 2004 03:38:18 -0000	1.36.2.21
***************
*** 1564,1574 ****
  
  class DocTestFailure(Exception):
!     """A DocTest example has failed in debugging mode
  
!     The exeption instance has variables:
  
!     - test: The DocTest object being run
  
!     - excample: The Example object that failed
  
      - got: the actual output
--- 1564,1574 ----
  
  class DocTestFailure(Exception):
!     """A DocTest example has failed in debugging mode.
  
!     The exception instance has variables:
  
!     - test: the DocTest object being run
  
!     - excample: the Example object that failed
  
      - got: the actual output
***************
*** 1580,1586 ****
  
  class DebugRunner(DocTestRunner):
!     r"""Run doc tests but raie an exception as soon as there is a failure
  
!        If an unexpected exception occurs, the exception is merely propigated
         to the caller:
  
--- 1580,1586 ----
  
  class DebugRunner(DocTestRunner):
!     r"""Run doc tests but raise an exception as soon as there is a failure.
  
!        If an unexpected exception occurs, the exception is merely propagated
         to the caller:
  
***************
*** 1618,1622 ****
           >>> failure.got
           '1\n'
- 
         """
  
--- 1618,1621 ----
***************
*** 1863,1868 ****
  
      This is useful for slipping pre-existing test functions into the
!     PyUnit framework. Optionally, set-up and tidy-up functions can be
!     supplied. As with TestCase, the tidy-up ('tearDown') function will
      always be called if the set-up ('setUp') function ran successfully.
      """
--- 1862,1867 ----
  
      This is useful for slipping pre-existing test functions into the
!     PyUnit framework.  Optionally, set-up and tidy-up functions can be
!     supplied.  As with TestCase, the tidy-up ('tearDown') function will
      always be called if the set-up ('setUp') function ran successfully.
      """
***************
*** 1933,1945 ****
                   setUp=lambda: None, tearDown=lambda: None):
      """
!     Convert doctest tests for a mudule to a unittest test suite
  
!     This tests convers each documentation string in a module that
!     contains doctest tests to a unittest test case. If any of the
!     tests in a doc string fail, then the test case fails. An error is
!     raised showing the name of the file containing the test and a
      (sometimes approximate) line number.
  
!     A module argument provides the module to be tested. The argument
      can be either a module or a module name.
  
--- 1932,1944 ----
                   setUp=lambda: None, tearDown=lambda: None):
      """
!     Convert doctest tests for a mudule to a unittest test suite.
  
!     This converts each documentation string in a module that
!     contains doctest tests to a unittest test case.  If any of the
!     tests in a doc string fail, then the test case fails.  An exception
!     is raised showing the name of the file containing the test and a
      (sometimes approximate) line number.
  
!     The `module` argument provides the module to be tested.  The argument
      can be either a module or a module name.
  
***************
*** 2017,2021 ****
  
      package
!       The name of a Python package. Text-file paths will be
        interpreted relative to the directory containing this package.
        The package may be supplied as a package object or as a dotted
--- 2016,2020 ----
  
      package
!       The name of a Python package.  Text-file paths will be
        interpreted relative to the directory containing this package.
        The package may be supplied as a package object or as a dotted
***************
*** 2023,2031 ****
  
      setUp
!       The name of a set-up function. This is called before running the
        tests in each file.
  
      tearDown
!       The name of a tear-down function. This is called after running the
        tests in each file.
  
--- 2022,2030 ----
  
      setUp
!       The name of a set-up function.  This is called before running the
        tests in each file.
  
      tearDown
!       The name of a tear-down function.  This is called after running the
        tests in each file.
  
***************
*** 2050,2059 ****
  
  def script_from_examples(s):
!     r"""Extract script from text with examples
  
!        The script_from_examples function converts text with examples
!        into a Python script.  Example input is converted to regular
!        code.  Example output and all other words are converted to
!        comments:
  
         >>> text = '''
--- 2049,2057 ----
  
  def script_from_examples(s):
!     r"""Extract script from text with examples.
  
!        Converts text with examples to a Python script.  Example input is
!        converted to regular code.  Example output and all other words
!        are converted to comments:
  
         >>> text = '''
***************
*** 2113,2123 ****
  def _want_comment(example):
      """
!     Return a comment containing the expected output for the given
!     example.
      """
      # Return the expected output, if any
      want = example.want
      if want:
!         if want[-1] == '\n': want = want[:-1]
          want = "\n#     ".join(want.split("\n"))
          want = "\n# Expected:\n#     %s" % want
--- 2111,2121 ----
  def _want_comment(example):
      """
!     Return a comment containing the expected output for the given example.
      """
      # Return the expected output, if any
      want = example.want
      if want:
!         if want[-1] == '\n':
!             want = want[:-1]
          want = "\n#     ".join(want.split("\n"))
          want = "\n# Expected:\n#     %s" % want
***************
*** 2125,2134 ****
  
  def testsource(module, name):
!     """Extract the test sources from a doctest test docstring as a script
  
      Provide the module (or dotted name of the module) containing the
      test to be debugged and the name (within the module) of the object
      with the doc string with tests to be debugged.
- 
      """
      module = _normalize_module(module)
--- 2123,2131 ----
  
  def testsource(module, name):
!     """Extract the test sources from a doctest docstring as a script.
  
      Provide the module (or dotted name of the module) containing the
      test to be debugged and the name (within the module) of the object
      with the doc string with tests to be debugged.
      """
      module = _normalize_module(module)
***************
*** 2142,2154 ****
  
  def debug_src(src, pm=False, globs=None):
!     """Debug a single doctest test doc string
! 
!     The string is provided directly
!     """
      testsrc = script_from_examples(src)
      debug_script(testsrc, pm, globs)
  
  def debug_script(src, pm=False, globs=None):
!     "Debug a test script"
      import pdb
  
--- 2139,2148 ----
  
  def debug_src(src, pm=False, globs=None):
!     """Debug a single doctest docstring, in argument `src`'"""
      testsrc = script_from_examples(src)
      debug_script(testsrc, pm, globs)
  
  def debug_script(src, pm=False, globs=None):
!     "Debug a test script.  `src` is the script, as a string."
      import pdb
  
***************
*** 2175,2184 ****
  
  def debug(module, name, pm=False):
!     """Debug a single doctest test doc string
  
      Provide the module (or dotted name of the module) containing the
      test to be debugged and the name (within the module) of the object
!     with the doc string with tests to be debugged.
! 
      """
      module = _normalize_module(module)
--- 2169,2177 ----
  
  def debug(module, name, pm=False):
!     """Debug a single doctest docstring.
  
      Provide the module (or dotted name of the module) containing the
      test to be debugged and the name (within the module) of the object
!     with the docstring with tests to be debugged.
      """
      module = _normalize_module(module)



More information about the Python-checkins mailing list