本文整理汇总了Python中test.string_tests.py方法的典型用法代码示例。如果您正苦于以下问题:Python string_tests.py方法的具体用法?Python string_tests.py怎么用?Python string_tests.py使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test.string_tests
的用法示例。
在下文中一共展示了string_tests.py方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rsplit_bytearray
# 需要导入模块: from test import string_tests [as 别名]
# 或者: from test.string_tests import py [as 别名]
def test_rsplit_bytearray(self):
self.assertEqual(b'a b'.rsplit(memoryview(b' ')), [b'a', b'b'])
# Optimizations:
# __iter__? (optimization)
# __reversed__? (optimization)
# XXX More string methods? (Those that don't use character properties)
# There are tests in string_tests.py that are more
# comprehensive for things like partition, etc.
# Unfortunately they are all bundled with tests that
# are not appropriate for bytes
# I've started porting some of those into bytearray_tests.py, we should port
# the rest that make sense (the code can be cleaned up to use modern
# unittest methods at the same time).
示例2: test_rsplit_bytearray
# 需要导入模块: from test import string_tests [as 别名]
# 或者: from test.string_tests import py [as 别名]
def test_rsplit_bytearray(self):
self.assertEqual(b'a b'.rsplit(memoryview(b' ')), [b'a', b'b'])
# Optimizations:
# __iter__? (optimization)
# __reversed__? (optimization)
# XXX More string methods? (Those that don't use character properties)
# There are tests in string_tests.py that are more
# comprehensive for things like split, partition, etc.
# Unfortunately they are all bundled with tests that
# are not appropriate for bytes
# I've started porting some of those into bytearray_tests.py, we should port
# the rest that make sense (the code can be cleaned up to use modern
# unittest methods at the same time).
示例3: test_compare
# 需要导入模块: from test import string_tests [as 别名]
# 或者: from test.string_tests import py [as 别名]
def test_compare(self):
if sys.flags.bytes_warning:
def bytes_warning():
return test.support.check_warnings(('', BytesWarning))
with bytes_warning():
b'' == ''
with bytes_warning():
b'' != ''
with bytes_warning():
bytearray(b'') == ''
with bytes_warning():
bytearray(b'') != ''
else:
self.skipTest("BytesWarning is needed for this test: use -bb option")
# Optimizations:
# __iter__? (optimization)
# __reversed__? (optimization)
# XXX More string methods? (Those that don't use character properties)
# There are tests in string_tests.py that are more
# comprehensive for things like split, partition, etc.
# Unfortunately they are all bundled with tests that
# are not appropriate for bytes
# I've started porting some of those into bytearray_tests.py, we should port
# the rest that make sense (the code can be cleaned up to use modern
# unittest methods at the same time).
示例4: test_compare
# 需要导入模块: from test import string_tests [as 别名]
# 或者: from test.string_tests import py [as 别名]
def test_compare(self):
def bytes_warning():
return test.support.check_warnings(('', BytesWarning))
with bytes_warning():
b'' == ''
with bytes_warning():
'' == b''
with bytes_warning():
b'' != ''
with bytes_warning():
'' != b''
with bytes_warning():
bytearray(b'') == ''
with bytes_warning():
'' == bytearray(b'')
with bytes_warning():
bytearray(b'') != ''
with bytes_warning():
'' != bytearray(b'')
with bytes_warning():
b'\0' == 0
with bytes_warning():
0 == b'\0'
with bytes_warning():
b'\0' != 0
with bytes_warning():
0 != b'\0'
# Optimizations:
# __iter__? (optimization)
# __reversed__? (optimization)
# XXX More string methods? (Those that don't use character properties)
# There are tests in string_tests.py that are more
# comprehensive for things like split, partition, etc.
# Unfortunately they are all bundled with tests that
# are not appropriate for bytes
# I've started porting some of those into bytearray_tests.py, we should port
# the rest that make sense (the code can be cleaned up to use modern
# unittest methods at the same time).
示例5: test_compare
# 需要导入模块: from test import string_tests [as 别名]
# 或者: from test.string_tests import py [as 别名]
def test_compare(self):
def bytes_warning():
return test.support.check_warnings(('', BytesWarning))
with bytes_warning():
b'' == ''
with bytes_warning():
'' == b''
with bytes_warning():
b'' != ''
with bytes_warning():
'' != b''
with bytes_warning():
bytearray(b'') == ''
with bytes_warning():
'' == bytearray(b'')
with bytes_warning():
bytearray(b'') != ''
with bytes_warning():
'' != bytearray(b'')
with bytes_warning():
b'\0' == 0
with bytes_warning():
0 == b'\0'
with bytes_warning():
b'\0' != 0
with bytes_warning():
0 != b'\0'
# Optimizations:
# __iter__? (optimization)
# __reversed__? (optimization)
# XXX More string methods? (Those that don't use character properties)
# There are tests in string_tests.py that are more
# comprehensive for things like partition, etc.
# Unfortunately they are all bundled with tests that
# are not appropriate for bytes
# I've started porting some of those into bytearray_tests.py, we should port
# the rest that make sense (the code can be cleaned up to use modern
# unittest methods at the same time).