本文整理汇总了Python中testtools.compat.unicode_output_stream函数的典型用法代码示例。如果您正苦于以下问题:Python unicode_output_stream函数的具体用法?Python unicode_output_stream怎么用?Python unicode_output_stream使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unicode_output_stream函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_unicode_encodings_not_wrapped
def test_unicode_encodings_not_wrapped(self):
"""A unicode encoding is left unwrapped as needs no error handler"""
sout = _FakeOutputStream()
sout.encoding = "utf-8"
self.assertIs(unicode_output_stream(sout), sout)
sout = _FakeOutputStream()
sout.encoding = "utf-16-be"
self.assertIs(unicode_output_stream(sout), sout)
开发者ID:Alexandr-Galko,项目名称:samba,代码行数:8,代码来源:test_compat.py
示例2: main
def main(argv, prepare_args=prepare_argv, find_tests=find_tests):
"""CLI entry point to adapt a test run to parallel testing."""
child_args = prepare_argv(argv)
test_ids = find_tests(argv)
# We could create a proxy object per test id if desired in future)
def parallelise_tests(suite):
test_ids = list(suite)[0]._test_ids
count = concurrency()
partitions = partition_tests(test_ids, count)
return [ListTestCase(partition, child_args) for partition in partitions]
suite = ConcurrentTestSuite(ListTestCase(test_ids, None), parallelise_tests)
if '--subunit' in argv:
runner = SubunitTestRunner(sys.stdout)
result = runner.run(suite)
else:
stream = unicode_output_stream(sys.stdout)
result = TextTestResult(stream)
result.startTestRun()
try:
suite.run(result)
finally:
result.stopTestRun()
if result.wasSuccessful():
return 0
return -1
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:25,代码来源:parallel.py
示例3: test_unicode_encodings_wrapped_when_str_is_not_unicode
def test_unicode_encodings_wrapped_when_str_is_not_unicode(self):
"""A unicode encoding is wrapped but needs no error handler"""
sout = _FakeOutputStream()
sout.encoding = "utf-8"
uout = unicode_output_stream(sout)
self.assertEqual(uout.errors, "strict")
uout.write(self.uni)
self.assertEqual([_b("pa\xc9\xaa\xce\xb8\xc9\x99n")], sout.writelog)
开发者ID:atlant2011,项目名称:samba,代码行数:8,代码来源:test_compat.py
示例4: run
def run(self, test):
"Run the given test case or test suite."
result = TextTestResult(unicode_output_stream(self.stdout))
result.startTestRun()
try:
return test.run(result)
finally:
result.stopTestRun()
开发者ID:IsCoolEntertainment,项目名称:debpkg_percona-xtrabackup,代码行数:8,代码来源:run.py
示例5: __init__
def __init__(self, ui, get_id, stream, previous_run=None, filter_tags=None):
"""Construct a CLITestResult writing to stream.
:param filter_tags: Tags that should be used to filter tests out. When
a tag in this set is present on a test outcome, the test is not
counted towards the test run count. If the test errors, then it is
still counted and the error is still shown.
"""
super(CLITestResult, self).__init__(ui, get_id, previous_run)
self.stream = unicode_output_stream(stream)
self.sep1 = _u('=' * 70 + '\n')
self.sep2 = _u('-' * 70 + '\n')
self.filter_tags = filter_tags or frozenset()
self.filterable_states = set(['success', 'uxsuccess', 'xfail', 'skip'])
开发者ID:testing-cabal,项目名称:testrepository,代码行数:14,代码来源:cli.py
示例6: test_stringio
def test_stringio(self):
"""A StringIO object should maybe get an ascii native str type"""
try:
from cStringIO import StringIO
newio = False
except ImportError:
from io import StringIO
newio = True
sout = StringIO()
soutwrapper = unicode_output_stream(sout)
soutwrapper.write(self.uni)
if newio:
self.assertEqual(self.uni, sout.getvalue())
else:
self.assertEqual("pa???n", sout.getvalue())
开发者ID:bz2,项目名称:testtools,代码行数:15,代码来源:test_compat.py
示例7: test_stringio
def test_stringio(self):
"""A StringIO object should maybe get an ascii native str type"""
try:
from cStringIO import StringIO
newio = False
except ImportError:
from io import StringIO
newio = True
sout = StringIO()
soutwrapper = unicode_output_stream(sout)
if newio:
self.expectFailure("Python 3 StringIO expects text not bytes",
self.assertThat, lambda: soutwrapper.write(self.uni),
Not(Raises(MatchesException(TypeError))))
soutwrapper.write(self.uni)
self.assertEqual("pa???n", sout.getvalue())
开发者ID:atlant2011,项目名称:samba,代码行数:16,代码来源:test_compat.py
示例8: test_unicode_encodings_not_wrapped_when_str_is_unicode
def test_unicode_encodings_not_wrapped_when_str_is_unicode(self):
# No wrapping needed if native str type is unicode
sout = _FakeOutputStream()
sout.encoding = "utf-8"
uout = unicode_output_stream(sout)
self.assertIs(uout, sout)
开发者ID:atlant2011,项目名称:samba,代码行数:6,代码来源:test_compat.py
示例9: test_partial_encoding_replace
def test_partial_encoding_replace(self):
"""A string which can be partly encoded correctly should be"""
sout = _FakeOutputStream()
sout.encoding = "iso-8859-7"
unicode_output_stream(sout).write(self.uni)
self.assertEqual([_b("pa?\xe8?n")], sout.writelog)
开发者ID:atlant2011,项目名称:samba,代码行数:6,代码来源:test_compat.py
示例10: test_bogus_encoding_becomes_ascii
def test_bogus_encoding_becomes_ascii(self):
"""A stream with a bogus encoding gets ascii/replace strings"""
sout = _FakeOutputStream()
sout.encoding = "bogus"
unicode_output_stream(sout).write(self.uni)
self.assertEqual([_b("pa???n")], sout.writelog)
开发者ID:atlant2011,项目名称:samba,代码行数:6,代码来源:test_compat.py
示例11: test_encoding_as_none_becomes_ascii
def test_encoding_as_none_becomes_ascii(self):
"""A stream with encoding value of None gets ascii/replace strings"""
sout = _FakeOutputStream()
sout.encoding = None
unicode_output_stream(sout).write(self.uni)
self.assertEqual([_b("pa???n")], sout.writelog)
开发者ID:atlant2011,项目名称:samba,代码行数:6,代码来源:test_compat.py
示例12: test_no_encoding_becomes_ascii
def test_no_encoding_becomes_ascii(self):
"""A stream with no encoding attribute gets ascii/replace strings"""
sout = _FakeOutputStream()
unicode_output_stream(sout).write(self.uni)
self.assertEqual([_b("pa???n")], sout.writelog)
开发者ID:atlant2011,项目名称:samba,代码行数:5,代码来源:test_compat.py
示例13: test_io_textwrapper
def test_io_textwrapper(self):
# textwrapper is unicode, should be returned as itself.
text_io = io.TextIOWrapper(io.BytesIO())
self.assertThat(unicode_output_stream(text_io), Is(text_io))
# To be sure...
unicode_output_stream(text_io).write(_u('foo'))
开发者ID:bz2,项目名称:testtools,代码行数:6,代码来源:test_compat.py
示例14: test_io_bytesio
def test_io_bytesio(self):
# io.BytesIO only accepts bytes so should be wrapped.
bytes_io = io.BytesIO()
self.assertThat(bytes_io, Not(Is(unicode_output_stream(bytes_io))))
# Will error if s was not wrapped properly.
unicode_output_stream(bytes_io).write(_u('foo'))
开发者ID:bz2,项目名称:testtools,代码行数:6,代码来源:test_compat.py
示例15: test_io_stringio
def test_io_stringio(self):
# io.StringIO only accepts unicode so should be returned as itself.
s = io.StringIO()
self.assertEqual(s, unicode_output_stream(s))
开发者ID:bz2,项目名称:testtools,代码行数:4,代码来源:test_compat.py
注:本文中的testtools.compat.unicode_output_stream函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论