mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Clean up the warnings filter use in test_unicode.
This commit is contained in:
parent
e1adeceb0c
commit
226b2303f4
1 changed files with 10 additions and 16 deletions
|
@ -31,19 +31,12 @@ def search_function(encoding):
|
|||
return None
|
||||
codecs.register(search_function)
|
||||
|
||||
class UnicodeTest(
|
||||
string_tests.CommonTest,
|
||||
string_tests.MixinStrUnicodeUserStringTest,
|
||||
string_tests.MixinStrUnicodeTest,
|
||||
):
|
||||
class UnicodeTest(string_tests.CommonTest,
|
||||
string_tests.MixinStrUnicodeUserStringTest,
|
||||
string_tests.MixinStrUnicodeTest):
|
||||
|
||||
type2test = str
|
||||
|
||||
def setUp(self):
|
||||
self.warning_filters = warnings.filters[:]
|
||||
|
||||
def tearDown(self):
|
||||
warnings.filters = self.warning_filters
|
||||
|
||||
def checkequalnofix(self, result, object, methodname, *args):
|
||||
method = getattr(object, methodname)
|
||||
realresult = method(*args)
|
||||
|
@ -283,11 +276,12 @@ class UnicodeTest(
|
|||
self.assertRaises(TypeError, 'replace'.replace, "r", 42)
|
||||
|
||||
def test_bytes_comparison(self):
|
||||
warnings.simplefilter('ignore', BytesWarning)
|
||||
self.assertEqual('abc' == b'abc', False)
|
||||
self.assertEqual('abc' != b'abc', True)
|
||||
self.assertEqual('abc' == bytearray(b'abc'), False)
|
||||
self.assertEqual('abc' != bytearray(b'abc'), True)
|
||||
with support.check_warnings():
|
||||
warnings.simplefilter('ignore', BytesWarning)
|
||||
self.assertEqual('abc' == b'abc', False)
|
||||
self.assertEqual('abc' != b'abc', True)
|
||||
self.assertEqual('abc' == bytearray(b'abc'), False)
|
||||
self.assertEqual('abc' != bytearray(b'abc'), True)
|
||||
|
||||
def test_comparison(self):
|
||||
# Comparisons:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue