summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-03-20 14:54:57 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-03-20 14:54:57 (GMT)
commit1dd49824df49d0132b21d90c12bb596da89d7a17 (patch)
tree7c76fae39c0d2160d8abcb5e908d7b46a9cd8f01 /Lib
parentee4c0b9dcfb550094cca086a032d44393b5c3642 (diff)
downloadcpython-1dd49824df49d0132b21d90c12bb596da89d7a17.zip
cpython-1dd49824df49d0132b21d90c12bb596da89d7a17.tar.gz
cpython-1dd49824df49d0132b21d90c12bb596da89d7a17.tar.bz2
Issue #23681: The -b option now affects comparisons of bytes with int.
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)