summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_bytes.py41
1 files changed, 28 insertions, 13 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index a9f64a0..ad28300 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -1338,20 +1338,35 @@ class AssortedBytesTest(unittest.TestCase):
b = bytearray()
self.assertFalse(b.replace(b'', b'') is b)
+ @unittest.skipUnless(sys.flags.bytes_warning,
+ "BytesWarning is needed for this test: use -bb option")
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")
+ 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)