summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-09 17:21:10 (GMT)
committerGuido van Rossum <guido@python.org>2007-10-09 17:21:10 (GMT)
commit1e35e765321311222f118197c79f2c3937035ffc (patch)
treeda550a2a6e205185eb215a9bd9e5cdabb1b92a12 /Lib
parent6ccd3f2dbcb98b33a71ffa6eae949deae797c09c (diff)
downloadcpython-1e35e765321311222f118197c79f2c3937035ffc.zip
cpython-1e35e765321311222f118197c79f2c3937035ffc.tar.gz
cpython-1e35e765321311222f118197c79f2c3937035ffc.tar.bz2
Patch #1049 by Thomas Lee.
Changes comparisons between PyBytes and PyUnicode to return unequal instead of raising TypeError.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_bytes.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 61950cc..c51a320 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -130,12 +130,14 @@ class BytesTest(unittest.TestCase):
self.assertEqual(str8("abc") < b"ab", False)
self.assertEqual(str8("abc") <= b"ab", False)
- # Bytes can't be compared to Unicode!
+ # Byte comparisons with unicode should always fail!
# Test this for all expected byte orders and Unicode character sizes
- self.assertRaises(TypeError, lambda: b"\0a\0b\0c" == "abc")
- self.assertRaises(TypeError, lambda: b"\0\0\0a\0\0\0b\0\0\0c" == "abc")
- self.assertRaises(TypeError, lambda: b"a\0b\0c\0" == "abc")
- self.assertRaises(TypeError, lambda: b"a\0\0\0b\0\0\0c\0\0\0" == "abc")
+ self.assertEqual(b"\0a\0b\0c" == "abc", False)
+ self.assertEqual(b"\0\0\0a\0\0\0b\0\0\0c" == "abc", False)
+ self.assertEqual(b"a\0b\0c\0" == "abc", False)
+ self.assertEqual(b"a\0\0\0b\0\0\0c\0\0\0" == "abc", False)
+ self.assertEqual(bytes() == str(), False)
+ self.assertEqual(bytes() != str(), True)
def test_nohash(self):
self.assertRaises(TypeError, hash, bytes())