• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(1456)  |  Call(1267)  |  Derive(0)  |  Import(189)
Convert doctest tests for a module 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.

If no argument is given, the calling module is used.

A number of options may be provided as keyword arguments:

setUp
  A set-up function.  This is called before running the
  tests in each file. The setUp function will be passed a DocTest
  object.  The setUp function can access the test globals as the
  globs attribute of the test passed.

tearDown
  A tear-down function.  This is called after running the
  tests in each file.  The tearDown function will be passed a DocTest
  object.  The tearDown function can access the test globals as the
  globs attribute of the test passed.

globs
  A dictionary containing initial global variables for the tests.

optionflags
   A set of doctest option flags expressed as an integer.

        def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
                 **options):
    """
    Convert doctest tests for a module 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.

    If no argument is given, the calling module is used.

    A number of options may be provided as keyword arguments:

    setUp
      A set-up function.  This is called before running the
      tests in each file. The setUp function will be passed a DocTest
      object.  The setUp function can access the test globals as the
      globs attribute of the test passed.

    tearDown
      A tear-down function.  This is called after running the
      tests in each file.  The tearDown function will be passed a DocTest
      object.  The tearDown function can access the test globals as the
      globs attribute of the test passed.

    globs
      A dictionary containing initial global variables for the tests.

    optionflags
       A set of doctest option flags expressed as an integer.
    """

    if test_finder is None:
        test_finder = DocTestFinder()

    module = _normalize_module(module)
    tests = test_finder.find(module, globs=globs, extraglobs=extraglobs)

    if not tests and sys.flags.optimize >=2:
        # Skip doctests when running with -O2
        suite = unittest.TestSuite()
        suite.addTest(SkipDocTestCase())
        return suite
    elif not tests:
        # Why do we want to do this? Because it reveals a bug that might
        # otherwise be hidden.
        raise ValueError(module, "has no tests")

    tests.sort()
    suite = unittest.TestSuite()

    for test in tests:
        if len(test.examples) == 0:
            continue
        if not test.filename:
            filename = module.__file__
            if filename[-4:] in (".pyc", ".pyo"):
                filename = filename[:-1]
            test.filename = filename
        suite.addTest(DocTestCase(test, **options))

    return suite
        


src/z/o/zope.testrunner-4.0.0b5/src/zope/testrunner/testrunner-ex/sample2/sampletests/test_1.py   zope.testrunner(Download)
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestA))
    suite.addTest(unittest.makeSuite(TestB))
    suite.addTest(unittest.makeSuite(TestNotMuch))
    suite.addTest(doctest.DocTestSuite(setUp=setUp))
    suite.addTest(doctest.DocFileSuite('../../sampletests.txt',

src/z/o/zope.testrunner-4.0.0b5/src/zope/testrunner/testrunner-ex/sample2/sampletests/testone.py   zope.testrunner(Download)
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestA))
    suite.addTest(unittest.makeSuite(TestB))
    suite.addTest(unittest.makeSuite(TestNotMuch))
    suite.addTest(doctest.DocTestSuite(setUp=setUp))
    suite.addTest(doctest.DocFileSuite('../../sampletests.txt',

src/z/o/zope.testrunner-4.0.0b5/src/zope/testrunner/testrunner-ex/sample2/sample21/sampletests.py   zope.testrunner(Download)
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestA))
    suite.addTest(unittest.makeSuite(TestB))
    suite.addTest(unittest.makeSuite(TestNotMuch))
    suite.addTest(doctest.DocTestSuite(setUp=setUp))
    suite.addTest(doctest.DocFileSuite('../../sampletests.txt',

src/z/o/zope.testrunner-4.0.0b5/src/zope/testrunner/testrunner-ex/sample1/sampletests/test_one.py   zope.testrunner(Download)
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestA))
    suite.addTest(unittest.makeSuite(TestB))
    suite.addTest(unittest.makeSuite(TestNotMuch))
    suite.addTest(doctest.DocTestSuite(setUp=setUp))
    suite.addTest(doctest.DocFileSuite('../../sampletests.txt',

src/z/o/zope.testrunner-4.0.0b5/src/zope/testrunner/testrunner-ex/sample1/sampletests/test122.py   zope.testrunner(Download)
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestA))
    suite.addTest(unittest.makeSuite(TestB))
    suite.addTest(unittest.makeSuite(TestNotMuch))
    s = doctest.DocTestSuite(setUp=setUp)
    s.layer = layer

src/z/o/zope.testrunner-4.0.0b5/src/zope/testrunner/testrunner-ex/sample1/sampletests/test121.py   zope.testrunner(Download)
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestA))
    suite.addTest(unittest.makeSuite(TestB))
    suite.addTest(unittest.makeSuite(TestNotMuch))
    s = doctest.DocTestSuite(setUp=setUp)
    s.layer = layer

src/z/o/zope.testrunner-4.0.0b5/src/zope/testrunner/testrunner-ex/sample1/sampletests/test12.py   zope.testrunner(Download)
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestA))
    suite.addTest(unittest.makeSuite(TestB))
    suite.addTest(unittest.makeSuite(TestNotMuch))
    s = doctest.DocTestSuite(setUp=setUp)
    s.layer = layer

src/z/o/zope.testrunner-4.0.0b5/src/zope/testrunner/testrunner-ex/sample1/sampletests/test112.py   zope.testrunner(Download)
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestA))
    suite.addTest(unittest.makeSuite(TestB))
    suite.addTest(unittest.makeSuite(TestNotMuch))
    s = doctest.DocTestSuite(setUp=setUp)
    s.layer = layer

src/z/o/zope.testrunner-4.0.0b5/src/zope/testrunner/testrunner-ex/sample1/sampletests/test111.py   zope.testrunner(Download)
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestA))
    suite.addTest(unittest.makeSuite(TestB))
    suite.addTest(unittest.makeSuite(TestNotMuch))
    s = doctest.DocTestSuite(setUp=setUp)
    s.layer = layer

src/z/o/zope.testrunner-4.0.0b5/src/zope/testrunner/testrunner-ex/sample1/sampletests/test11.py   zope.testrunner(Download)
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestA))
    suite.addTest(unittest.makeSuite(TestB))
    suite.addTest(unittest.makeSuite(TestNotMuch))
    s = doctest.DocTestSuite(setUp=setUp)
    s.layer = layer

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next