summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-04-09 00:49:13 +0000
committerGuido van Rossum <guido@python.org>2007-04-09 00:49:13 +0000
commitb3bd4d5509061c70538056f0c769478171fded3d (patch)
tree1d253d29e08af85ddcf6d0a1011f4128851c0354 /Lib
parentdc18b61cea08c7527406b3bfa58a52604a5980f8 (diff)
downloadcpython-b3bd4d5509061c70538056f0c769478171fded3d.tar.gz
Bytes should never equal unicode.
Add tests for str <cmpop> bytes.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_bytes.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 2999aa6545..e90bceeabc 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -114,6 +114,27 @@ class BytesTest(unittest.TestCase):
self.assertEqual(b"abc" < "ab", False)
self.assertEqual(b"abc" <= "ab", False)
+ self.assertEqual("abc" == b"abc", True)
+ self.assertEqual("ab" != b"abc", True)
+ self.assertEqual("ab" <= b"abc", True)
+ self.assertEqual("ab" < b"abc", True)
+ self.assertEqual("abc" >= b"ab", True)
+ self.assertEqual("abc" > b"ab", True)
+
+ self.assertEqual("abc" != b"abc", False)
+ self.assertEqual("ab" == b"abc", False)
+ self.assertEqual("ab" > b"abc", False)
+ self.assertEqual("ab" >= b"abc", False)
+ self.assertEqual("abc" < b"ab", False)
+ self.assertEqual("abc" <= b"ab", False)
+
+ # But they should never compare equal to Unicode!
+ # Test this for all expected byte orders and Unicode character sizes
+ self.assertEqual(b"\0a\0b\0c" == u"abc", False)
+ self.assertEqual(b"\0\0\0a\0\0\0b\0\0\0c" == u"abc", False)
+ self.assertEqual(b"a\0b\0c\0" == u"abc", False)
+ self.assertEqual(b"a\0\0\0b\0\0\0c\0\0\0" == u"abc", False)
+
def test_nohash(self):
self.assertRaises(TypeError, hash, bytes())