本文整理汇总了Python中test.test_support.run_doctest函数的典型用法代码示例。如果您正苦于以下问题:Python run_doctest函数的具体用法?Python run_doctest怎么用?Python run_doctest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_doctest函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_main
def test_main(verbose=None):
from test import test_urllib2
test_support.run_doctest(test_urllib2, verbose)
test_support.run_doctest(urllib2, verbose)
tests = (TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests, RequestTests)
test_support.run_unittest(*tests)
开发者ID:int3,项目名称:jython,代码行数:7,代码来源:test_urllib2.py
示例2: test_libref_examples
def test_libref_examples(self):
s = """
Examples from the Library Reference: Doc/lib/libgetopt.tex
An example using only Unix style options:
>>> import getopt
>>> args = '-a -b -cfoo -d bar a1 a2'.split()
>>> args
['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']
>>> optlist, args = getopt.getopt(args, 'abc:d:')
>>> optlist
[('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]
>>> args
['a1', 'a2']
Using long option names is equally easy:
>>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'
>>> args = s.split()
>>> args
['--condition=foo', '--testing', '--output-file', 'abc.def', '-x', 'a1', 'a2']
>>> optlist, args = getopt.getopt(args, 'x', [
... 'condition=', 'output-file=', 'testing'])
>>> optlist
[('--condition', 'foo'), ('--testing', ''), ('--output-file', 'abc.def'), ('-x', '')]
>>> args
['a1', 'a2']
"""
import types
m = types.ModuleType("libreftest", s)
run_doctest(m, verbose)
开发者ID:CaoYouXin,项目名称:myfirstapicloudapp,代码行数:35,代码来源:test_getopt.py
示例3: test_main
def test_main(verbose=None):
NamedTupleDocs = doctest.DocTestSuite(module=collections)
test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs,
TestCollectionABCs, TestCounter,
TestOrderedDict, GeneralMappingTests, SubclassMappingTests]
test_support.run_unittest(*test_classes)
test_support.run_doctest(collections, verbose)
开发者ID:carlosrcjunior,项目名称:BCC-2s13-PI4-WebCrawler,代码行数:7,代码来源:test_collections.py
示例4: test_main
def test_main(arith=False, verbose=None):
""" Execute the tests.
Runs all arithmetic tests if arith is True or if the "decimal" resource
is enabled in regrtest.py
"""
init()
global TEST_ALL
TEST_ALL = arith or is_resource_enabled('decimal')
test_classes = [
DecimalExplicitConstructionTest,
DecimalImplicitConstructionTest,
DecimalArithmeticOperatorsTest,
DecimalUseOfContextTest,
DecimalUsabilityTest,
DecimalPythonAPItests,
ContextAPItests,
DecimalTest,
WithStatementTest,
]
try:
run_unittest(*test_classes)
import decimal as DecimalModule
run_doctest(DecimalModule, verbose)
finally:
setcontext(ORIGINAL_CONTEXT)
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:29,代码来源:test_decimal.py
示例5: test_main
def test_main():
test_support.run_unittest(
PickleTests,
PicklerTests,
PersPicklerTests
)
test_support.run_doctest(pickle)
开发者ID:B-Rich,项目名称:breve,代码行数:7,代码来源:test_pickle.py
示例6: test_main
def test_main(verbose=None):
from test import test_sets
test_support.run_unittest(
TestSetOfSets,
TestExceptionPropagation,
TestBasicOpsEmpty,
TestBasicOpsSingleton,
TestBasicOpsTuple,
TestBasicOpsTriple,
TestBinaryOps,
TestUpdateOps,
TestMutate,
TestSubsetEqualEmpty,
TestSubsetEqualNonEmpty,
TestSubsetEmptyNonEmpty,
TestSubsetPartial,
TestSubsetNonOverlap,
TestOnlySetsNumeric,
TestOnlySetsDict,
TestOnlySetsOperator,
TestOnlySetsTuple,
TestOnlySetsString,
TestOnlySetsGenerator,
TestCopyingEmpty,
TestCopyingSingleton,
TestCopyingTriple,
TestCopyingTuple,
TestCopyingNested,
TestIdentities,
)
test_support.run_doctest(test_sets, verbose)
开发者ID:OS2World,项目名称:APP-INTERNET-torpak_2,代码行数:31,代码来源:test_sets.py
示例7: test_main
def test_main():
test_support.run_unittest(
ReferencesTestCase,
MappingTestCase,
WeakValueDictionaryTestCase,
WeakKeyDictionaryTestCase,
)
test_support.run_doctest(sys.modules[__name__])
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:test_weakref.py
示例8: test_main
def test_main(verbose=None):
# Obscure: import this module as test.test_descrtut instead of as
# plain test_descrtut because the name of this module works its way
# into the doctest examples, and unless the full test.test_descrtut
# business is used the name can change depending on how the test is
# invoked.
from test import test_support, test_descrtut
test_support.run_doctest(test_descrtut, verbose)
开发者ID:321boom,项目名称:The-Powder-Toy,代码行数:8,代码来源:test_descrtut.py
示例9: test_main
def test_main(verbose=None):
if sys.flags.optimize >= 2:
print >>sys.stderr, "test_collections -- skipping some tests due to -O flag."
sys.stderr.flush()
NamedTupleDocs = doctest.DocTestSuite(module=collections)
test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs, TestCollectionABCs]
test_support.run_unittest(*test_classes)
test_support.run_doctest(collections, verbose)
开发者ID:andrcmdr,项目名称:unladen-swallow,代码行数:8,代码来源:test_collections.py
示例10: test_main
def test_main():
test_support.run_unittest(
PickleTests,
PicklerTests,
PersPicklerTests,
PicklerUnpicklerObjectTests,
PickleBigmemPickleTests,
)
test_support.run_doctest(pickle)
开发者ID:mxxu,项目名称:pyston,代码行数:9,代码来源:test_pickle.py
示例11: test_main
def test_main():
test_support.run_unittest(SyntaxTestCase)
if test_support.due_to_ironpython_bug("http://ironpython.codeplex.com/workitem/28171"):
return
from test import test_syntax
with test_support.check_py3k_warnings(("backquote not supported", SyntaxWarning)):
test_support.run_doctest(test_syntax, verbosity=True)
开发者ID:jschementi,项目名称:iron,代码行数:9,代码来源:test_syntax.py
示例12: test_main
def test_main(verbose=None):
import doctest
from test import test_support, test_generators
if 0: # change to 1 to run forever (to check for leaks)
while 1:
doctest.master = None
test_support.run_doctest(test_generators, verbose)
print ".",
else:
test_support.run_doctest(test_generators, verbose)
开发者ID:OS2World,项目名称:APP-INTERNET-torpak_2,代码行数:10,代码来源:test_generators.py
示例13: test_main
def test_main():
test_support.run_unittest(
ReferencesTestCase,
MappingTestCase,
WeakValueDictionaryTestCase,
WeakKeyDictionaryTestCase,
SubclassableWeakrefTestCase,
)
if not test_support.due_to_ironpython_bug("http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=21116"):
test_support.run_doctest(sys.modules[__name__])
开发者ID:BillyboyD,项目名称:main,代码行数:10,代码来源:test_weakref.py
示例14: test_main
def test_main(arith=False, verbose=None, todo_tests=None, debug=None):
""" Execute the tests.
Runs all arithmetic tests if arith is True or if the "decimal" resource
is enabled in regrtest.py
"""
init()
global TEST_ALL, DEBUG
TEST_ALL = arith or is_resource_enabled("decimal")
DEBUG = debug
if todo_tests is None:
test_classes = [
DecimalExplicitConstructionTest,
DecimalImplicitConstructionTest,
DecimalArithmeticOperatorsTest,
DecimalFormatTest,
DecimalUseOfContextTest,
DecimalUsabilityTest,
DecimalPythonAPItests,
ContextAPItests,
DecimalTest,
WithStatementTest,
ContextFlags,
]
else:
test_classes = [DecimalTest]
# Dynamically build custom test definition for each file in the test
# directory and add the definitions to the DecimalTest class. This
# procedure insures that new files do not get skipped.
for filename in os.listdir(directory):
if ".decTest" not in filename or filename.startswith("."):
continue
head, tail = filename.split(".")
if todo_tests is not None and head not in todo_tests:
continue
tester = lambda self, f=filename: self.eval_file(directory + f)
setattr(DecimalTest, "test_" + head, tester)
del filename, head, tail, tester
try:
run_unittest(*test_classes)
if todo_tests is None:
import decimal as DecimalModule
run_doctest(DecimalModule, verbose)
finally:
setcontext(ORIGINAL_CONTEXT)
开发者ID:harry159821,项目名称:sl4a,代码行数:50,代码来源:test_decimal.py
示例15: test_main
def test_main(verbose=None):
import sys
from test import test_support
from test import test_genexps
test_support.run_doctest(test_genexps, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in xrange(len(counts)):
test_support.run_doctest(test_genexps, verbose)
gc.collect()
counts[i] = sys.gettotalrefcount()
print counts
开发者ID:enyst,项目名称:plexnet,代码行数:15,代码来源:test_genexps.py
示例16: test_main
def test_main():
from test import test_doctest2
EXPECTED = 19
f, t = test_support.run_doctest(test_doctest2)
if t != EXPECTED:
raise test_support.TestFailed("expected %d tests to run, not %d" %
(EXPECTED, t))
开发者ID:AojiaoZero,项目名称:CrossApp,代码行数:7,代码来源:test_doctest2.py
示例17: test_main
def test_main(verbose=None):
test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC)
test_support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in xrange(len(counts)):
test_support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print counts
# doctest the examples in the library reference
test_support.run_doctest(sys.modules[__name__], verbose)
开发者ID:mancoast,项目名称:CPythonPyc_test,代码行数:16,代码来源:230_test_itertools.py
示例18: test_main
def test_main():
if verbose:
print 'starting...'
# This displays the tokenization of tokenize_tests.py to stdout, and
# regrtest.py checks that this equals the expected output (in the
# test/output/ directory).
f = open(findfile('tokenize_tests' + os.extsep + 'txt'))
tokenize(f.readline)
f.close()
# Now run test_roundtrip() over tokenize_test.py too, and over all
# (if the "compiler" resource is enabled) or a small random sample (if
# "compiler" is not enabled) of the test*.py files.
f = findfile('tokenize_tests' + os.extsep + 'txt')
test_roundtrip(f)
testdir = os.path.dirname(f) or os.curdir
testfiles = glob.glob(testdir + os.sep + 'test*.py')
if not is_resource_enabled('compiler'):
testfiles = random.sample(testfiles, 10)
for f in testfiles:
test_roundtrip(f)
# Test detecton of IndentationError.
sampleBadText = """\
def foo():
bar
baz
"""
try:
for tok in generate_tokens(StringIO(sampleBadText).readline):
pass
except IndentationError:
pass
else:
raise TestFailed("Did not detect IndentationError:")
# Run the doctests in this module.
from test import test_tokenize # i.e., this module
from test.test_support import run_doctest
run_doctest(test_tokenize)
if verbose:
print 'finished'
开发者ID:B-Rich,项目名称:breve,代码行数:47,代码来源:test_tokenize.py
示例19: test_main
def test_main():
if test_support.is_jython:
# Probably CPython GC specific (possibly even Jython bugs)
del ReferencesTestCase.test_callback_in_cycle_resurrection
del ReferencesTestCase.test_callbacks_on_callback
# Jython allows types to be weakref'd that CPython doesn't
del MappingTestCase.test_weak_keyed_bad_delitem
# CPython GC specific
del MappingTestCase.test_weak_keyed_cascading_deletes
test_support.run_unittest(
ReferencesTestCase,
MappingTestCase,
WeakValueDictionaryTestCase,
WeakKeyDictionaryTestCase,
)
test_support.run_doctest(sys.modules[__name__])
开发者ID:Alex-CS,项目名称:sonify,代码行数:18,代码来源:test_weakref.py
示例20: test_main
def test_main():
from test import test_xml_etree, test_xml_etree_c
# Run the tests specific to the C implementation
test_support.run_doctest(test_xml_etree_c, verbosity=True)
# Assign the C implementation before running the doctests
# Patch the __name__, to prevent confusion with the pure Python test
pyET = test_xml_etree.ET
py__name__ = test_xml_etree.__name__
test_xml_etree.ET = cET
if __name__ != '__main__':
test_xml_etree.__name__ = __name__
try:
# Run the same test suite as xml.etree.ElementTree
test_xml_etree.test_main(module_name='xml.etree.cElementTree')
finally:
test_xml_etree.ET = pyET
test_xml_etree.__name__ = py__name__
开发者ID:2uller,项目名称:LotF,代码行数:19,代码来源:test_xml_etree_c.py
注:本文中的test.test_support.run_doctest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论