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
def test_suite():
from doctest import DocTestSuite
return DocTestSuite()
if __name__ == '__main__':
unittest.main()
src/s/a/sage-HEAD/local/lib/python2.4/site-packages/transaction/tests/test_SampleResourceManager.py sage(Download)
def test_suite():
from doctest import DocTestSuite
return DocTestSuite()
if __name__ == '__main__':
unittest.main()
src/z/o/ZODB3-3.10.0b8/src/ZODB/tests/sampledm.py ZODB3(Download)
def test_suite():
from doctest import DocTestSuite
return DocTestSuite()
src/t/r/transaction-1.1.1/transaction/tests/test_SampleResourceManager.py transaction(Download)
def test_suite():
from doctest import DocTestSuite
return DocTestSuite()
# additional_tests is for setuptools "setup.py test" support
additional_tests = test_suite
src/t/r/transaction-1.1.1/transaction/tests/sampledm.py transaction(Download)
def test_suite():
from doctest import DocTestSuite
return DocTestSuite()
if __name__ == '__main__':
unittest.main()
src/t/r/transaction-1.1.1/transaction/tests/test_SampleDataManager.py transaction(Download)
##############################################################################
"""Sample objects for use in tests
"""
from doctest import DocTestSuite
class DataManager(object):
"""Sample data manager
def test_suite():
return DocTestSuite()
# additional_tests is for setuptools "setup.py test" support
additional_tests = test_suite
if __name__ == '__main__':
src/y/o/yoma-HEAD/yoma.nsobject/trunk/src/yoma/nsobject/tests.py yoma(Download)
import objc from unittest import TestSuite, main from doctest import DocFileSuite, DocTestSuite, ELLIPSIS, NORMALIZE_WHITESPACE from zope.component.testing import setUp, tearDown
def test_suite():
tests = [
DocFileSuite('README.txt',
setUp=setUp, tearDown=tearDown,
optionflags=optionflags),
DocTestSuite('yoma.nsobject.adapters', optionflags=optionflags),
DocTestSuite('yoma.nsobject.objectproxy',
setUp=setUp,
tearDown=tearDown,
optionflags=optionflags),
DocTestSuite('yoma.nsobject.listproxy',
tearDown=tearDown,
optionflags=optionflags),
DocTestSuite('yoma.nsobject.dictproxy',
setUp=setUp,
tearDown=tearDown,
optionflags=optionflags),
DocTestSuite('yoma.nsobject.setup',
]
if objc.__version__ not in ('2.0.1',):
tests.append(
DocTestSuite('yoma.nsobject.keydependence',
setUp=setUp,
tearDown=tearDown,
optionflags=optionflags),
src/y/o/yoma-HEAD/yoma.nspersistent/trunk/src/yoma/nspersistent/tests.py yoma(Download)
""" from unittest import TestSuite, main from doctest import DocFileSuite, DocTestSuite, ELLIPSIS, NORMALIZE_WHITESPACE from zope.component.testing import setUp, tearDown
def test_suite():
return TestSuite((
DocFileSuite('README.txt',
setUp=setUp, tearDown=tearDown,
optionflags=optionflags),
DocTestSuite('yoma.nspersistent.setup',
setUp=setUp, tearDown=tearDown,
optionflags=optionflags),
DocTestSuite('yoma.nspersistent.archive',
setUp=setUp, tearDown=tearDown,
optionflags=optionflags),
DocTestSuite('yoma.nspersistent.applicationstorage',
setUp=setUp, tearDown=tearDown,
optionflags=optionflags),
DocTestSuite('yoma.nspersistent.zodbdocument',
src/e/r/errorhandler-1.1.1/errorhandler/tests.py errorhandler(Download)
import logging from os.path import dirname,join,pardir import unittest from doctest import DocFileSuite,DocTestSuite,REPORT_NDIFF,ELLIPSIS from errorhandler import ErrorHandler class TestErrorHandler:
optionflags=options,
*glob(join(dirname(__file__),pardir,'docs','*.txt'))
),
DocTestSuite(setUp=setUp,
tearDown=tearDown,
optionflags=options),
))
src/p/y/pymoul-HEAD/pymoul/trunk/utilities/distutils_iss.py pymoul(Download)
def test_suite():
import unittest
from doctest import DocTestSuite
return unittest.TestSuite((
DocTestSuite(__name__),
))
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next