本文整理汇总了Python中unittest.runner._WritelnDecorator函数的典型用法代码示例。如果您正苦于以下问题:Python _WritelnDecorator函数的具体用法?Python _WritelnDecorator怎么用?Python _WritelnDecorator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_WritelnDecorator函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fixture_context_multiple_names_no_common_ancestors
def test_fixture_context_multiple_names_no_common_ancestors(self):
stream = _WritelnDecorator(StringIO())
res = _TextTestResult(stream, 0, 2)
wd = os.path.join(support, 'ltfn')
l = loader.TestLoader(workingDir=wd)
suite = l.loadTestsFromNames(
['test_pak1.test_mod',
'test_pak2:test_two_two',
'test_mod'])
print suite
suite(res)
res.printErrors()
print stream.getvalue()
assert not res.errors, res.errors
assert not res.failures, res.failures
assert 'state' in sys.modules, \
"Context not load state module"
m = sys.modules['state']
print "state", m.called
expect = ['test_pak1.setup',
'test_pak1.test_mod.setup',
'test_pak1.test_mod.test_one_mod_one',
'test_pak1.test_mod.teardown',
'test_pak1.teardown',
'test_pak2.setup',
'test_pak2.test_two_two',
'test_pak2.teardown',
'test_mod.setup',
'test_mod.test_mod',
'test_mod.teardown']
self.assertEqual(m.called, expect, diff(expect, m.called))
示例2: _make_result
def _make_result(verbose, failfast):
"""Creates a TextTestResult object that writes a stream to a StringIO"""
stream = _WritelnDecorator(StringIO())
result = unittest.TextTestResult(stream, True, verbose)
result.buffer = False
result.failfast = failfast
return result
示例3: __init__
def __init__(
self,
stream=None,
descriptions=True,
verbosity=1,
failfast=False,
buffer=False,
resultclass=None,
warnings=None,
*,
tb_locals=False,
process_number=multiprocessing.cpu_count(),
result_collector_class=None
):
if stream is None:
stream = sys.stderr
self.stream = _WritelnDecorator(stream)
self.descriptions = descriptions
self.verbosity = verbosity
self.failfast = failfast
self.buffer = buffer
self.tb_locals = tb_locals
self.warnings = warnings
self.process_number = process_number
if resultclass is not None:
if isinstance(resultclass, collections.Iterable):
self.resultclass = resultclass
else:
self.resultclass = (resultclass,)
if result_collector_class is not None:
self.result_collector_class = result_collector_class
示例4: makeResult
def makeResult():
stream = _WritelnDecorator(StringIO())
result = resultClass(stream, descriptions=1, verbosity=config.verbosity, config=config)
plug_result = config.plugins.prepareTestResult(result)
if plug_result:
return plug_result
return result
示例5: prepareTestResult
def prepareTestResult(self, result):
result.__failures = []
result.__errors = []
result.__tests_run = 0
result.__start_time = time.time()
result.stream = _WritelnDecorator(open(os.devnull, 'w'))
self._result = result
示例6: set_stream
def set_stream(self, streaming):
"""Set the streaming boolean option to stream TAP directly to stdout.
The test runner default output will be suppressed in favor of TAP.
"""
self.stream = _WritelnDecorator(open(os.devnull, "w"))
_tracker.streaming = streaming
_tracker.stream = sys.stdout
示例7: __init__
def __init__(self, stream=sys.stderr, descriptions=True, verbosity=1,
failfast=False, buffer=False, resultclass=None):
self.stream = _WritelnDecorator(stream)
self.descriptions = descriptions
self.verbosity = verbosity
self.failfast = False
self.buffer = buffer
if resultclass is not None:
self.resultclass = resultclass
示例8: buildReport
def buildReport(self, add_status):
subject, summary = self._buildSummary(add_status)
body = StringIO()
body.write(summary)
for test in self.unexpectedSuccesses:
body.write("UNEXPECTED SUCCESS: %s\n" % self.getDescription(test))
self.stream = _WritelnDecorator(body)
self.printErrors()
return subject, body.getvalue()
示例9: __init__
def __init__(self, title, verbosity):
super(NeoTestRunner, self).__init__(
_WritelnDecorator(sys.stderr), False, verbosity)
self._title = title
self.modulesStats = {}
self.failedImports = {}
self.run_dict = defaultdict(int)
self.time_dict = defaultdict(int)
self.temp_directory = getTempDirectory()
示例10: test_mp_process_args_pickleable
def test_mp_process_args_pickleable():
test = case.Test(T('runTest'))
config = Config()
config.multiprocess_workers = 2
config.multiprocess_timeout = 0.1
runner = multiprocess.MultiProcessTestRunner(
stream=_WritelnDecorator(sys.stdout),
verbosity=2,
loaderClass=TestLoader,
config=config)
runner.run(test)
示例11: create_result_object
def create_result_object(self):
result = self.resultClass(
_WritelnDecorator(StringIO()),
descriptions=1,
verbosity=self.config.verbosity,
config=self.config
)
plug_result = self.config.plugins.prepareTestResult(result)
if plug_result:
return plug_result
return result
示例12: test_load_nonsense_name
def test_load_nonsense_name(self):
ctx = os.path.join(support, 'ctx')
l = loader.TestLoader(workingDir=ctx)
suite = l.loadTestsFromName('fred!')
res = _TextTestResult(
stream=_WritelnDecorator(sys.stdout),
descriptions=0, verbosity=1)
suite(res)
print res.errors
assert res.errors, "Expected errors but got none"
assert not res.failures, res.failures
示例13: test_issue_269
def test_issue_269(self):
"""Test classes that raise exceptions in __init__ do not stop test run
"""
wdir = os.path.join(support, 'issue269')
l = loader.TestLoader(workingDir=wdir)
suite = l.loadTestsFromName('test_bad_class')
res = _TextTestResult(
stream=_WritelnDecorator(sys.stdout),
descriptions=0, verbosity=1)
suite(res)
print res.errors
self.assertEqual(len(res.errors), 1)
assert 'raise Exception("pow")' in res.errors[0][1]
示例14: __init__
def __init__(self, stream=None, descriptions=True, verbosity=1,
failfast=False, buffer=False, resultclass=None,
warnings=None):
if stream is None:
stream = sys.stderr
self.stream = runner._WritelnDecorator(stream)
self.descriptions = descriptions
self.verbosity = verbosity
self.failfast = failfast
self.buffer = buffer
self.warnings = warnings
if resultclass is not None:
self.resultclass = resultclass
示例15: test_mp_process_args_pickleable
def test_mp_process_args_pickleable():
# TODO(Kumar) this test needs to be more succint.
# If you start seeing it timeout then perhaps we need to skip it again.
# raise SkipTest('this currently gets stuck in poll() 90% of the time')
test = case.Test(T('runTest'))
config = Config()
config.multiprocess_workers = 2
config.multiprocess_timeout = 5
runner = multiprocess.MultiProcessTestRunner(
stream=_WritelnDecorator(sys.stdout),
verbosity=10,
loaderClass=TestLoader,
config=config)
runner.run(test)