summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bytes.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2008-10-17 01:50:37 (GMT)
committerBarry Warsaw <barry@python.org>2008-10-17 01:50:37 (GMT)
commit9e9dcd6d4225faa6a8b19120f009e0253d16ab92 (patch)
treec76fbecc98e4f8d86073f3245e84bdacad3c6ec2 /Lib/test/test_bytes.py
parente94a37f3a1b4bbd46f50922edcdf9293954fdd01 (diff)
downloadcpython-9e9dcd6d4225faa6a8b19120f009e0253d16ab92.zip
cpython-9e9dcd6d4225faa6a8b19120f009e0253d16ab92.tar.gz
cpython-9e9dcd6d4225faa6a8b19120f009e0253d16ab92.tar.bz2
STINNER Victor (haypo)'s patch for bug 3988, Byte warning mode and b'' != ''
Also, his patch to runtests.sh to pass the -bb option (issue 4125).
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r--Lib/test/test_bytes.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 81d2dad..c368143 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -9,6 +9,7 @@ import os
import re
import sys
import copy
+import operator
import pickle
import tempfile
import unittest
@@ -863,6 +864,17 @@ class AssortedBytesTest(unittest.TestCase):
b = bytearray()
self.failIf(b.replace(b'', b'') is b)
+ def test_compare(self):
+ if sys.flags.bytes_warning:
+ warnings.simplefilter('error', BytesWarning)
+ self.assertRaises(BytesWarning, operator.eq, b'', '')
+ self.assertRaises(BytesWarning, operator.ne, b'', '')
+ self.assertRaises(BytesWarning, operator.eq, bytearray(b''), '')
+ self.assertRaises(BytesWarning, operator.ne, bytearray(b''), '')
+ else:
+ # raise test.support.TestSkipped("BytesWarning is needed for this test: use -bb option")
+ pass
+
# Optimizations:
# __iter__? (optimization)
# __reversed__? (optimization)