diff options
author | Brett Cannon <bcannon@gmail.com> | 2010-03-20 22:22:22 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2010-03-20 22:22:22 (GMT) |
commit | 226b2303f425d3337804deed75afa10565e272f4 (patch) | |
tree | eddf3b9d84a36f34551c485f3f3469ff18fa4d0e /Lib/test/test_unicode.py | |
parent | e1adeceb0c2daafe36011300594650c906747674 (diff) | |
download | cpython-226b2303f425d3337804deed75afa10565e272f4.zip cpython-226b2303f425d3337804deed75afa10565e272f4.tar.gz cpython-226b2303f425d3337804deed75afa10565e272f4.tar.bz2 |
Clean up the warnings filter use in test_unicode.
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r-- | Lib/test/test_unicode.py | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index ef9aa9e..1da2d14 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -31,18 +31,11 @@ def search_function(encoding): return None codecs.register(search_function) -class UnicodeTest( - string_tests.CommonTest, - string_tests.MixinStrUnicodeUserStringTest, - string_tests.MixinStrUnicodeTest, - ): - type2test = str - - def setUp(self): - self.warning_filters = warnings.filters[:] +class UnicodeTest(string_tests.CommonTest, + string_tests.MixinStrUnicodeUserStringTest, + string_tests.MixinStrUnicodeTest): - def tearDown(self): - warnings.filters = self.warning_filters + type2test = str def checkequalnofix(self, result, object, methodname, *args): method = getattr(object, methodname) @@ -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: |