Commit 226b2303 authored by Brett Cannon's avatar Brett Cannon

Clean up the warnings filter use in test_unicode.

parent e1adeceb
...@@ -31,18 +31,11 @@ def search_function(encoding): ...@@ -31,18 +31,11 @@ def search_function(encoding):
return None return None
codecs.register(search_function) codecs.register(search_function)
class UnicodeTest( class UnicodeTest(string_tests.CommonTest,
string_tests.CommonTest, string_tests.MixinStrUnicodeUserStringTest,
string_tests.MixinStrUnicodeUserStringTest, string_tests.MixinStrUnicodeTest):
string_tests.MixinStrUnicodeTest,
):
type2test = str
def setUp(self):
self.warning_filters = warnings.filters[:]
def tearDown(self): type2test = str
warnings.filters = self.warning_filters
def checkequalnofix(self, result, object, methodname, *args): def checkequalnofix(self, result, object, methodname, *args):
method = getattr(object, methodname) method = getattr(object, methodname)
...@@ -283,11 +276,12 @@ class UnicodeTest( ...@@ -283,11 +276,12 @@ class UnicodeTest(
self.assertRaises(TypeError, 'replace'.replace, "r", 42) self.assertRaises(TypeError, 'replace'.replace, "r", 42)
def test_bytes_comparison(self): def test_bytes_comparison(self):
warnings.simplefilter('ignore', BytesWarning) with support.check_warnings():
self.assertEqual('abc' == b'abc', False) warnings.simplefilter('ignore', BytesWarning)
self.assertEqual('abc' != b'abc', True) self.assertEqual('abc' == b'abc', False)
self.assertEqual('abc' == bytearray(b'abc'), False) self.assertEqual('abc' != b'abc', True)
self.assertEqual('abc' != bytearray(b'abc'), True) self.assertEqual('abc' == bytearray(b'abc'), False)
self.assertEqual('abc' != bytearray(b'abc'), True)
def test_comparison(self): def test_comparison(self):
# Comparisons: # Comparisons:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment