summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-04-09 00:43:24 (GMT)
committerGuido van Rossum <guido@python.org>2007-04-09 00:43:24 (GMT)
commit343e97ff7f939fc16d144a196a95ecf2e82c061e (patch)
tree96fd769c99919c8116eca192247ea7d1647fd64d /Lib/test
parent62cbc8a2618a41c28b8ec25f70f85f2da17705f2 (diff)
downloadcpython-343e97ff7f939fc16d144a196a95ecf2e82c061e.zip
cpython-343e97ff7f939fc16d144a196a95ecf2e82c061e.tar.gz
cpython-343e97ff7f939fc16d144a196a95ecf2e82c061e.tar.bz2
For Make Benefit Glorious Nation of Backwards Compatibility,
bytes objects can now be compared to anything that supports the buffer API.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_bytes.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 028cbfd..2999aa6 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -99,6 +99,21 @@ class BytesTest(unittest.TestCase):
self.failIf(b3 < b2)
self.failIf(b3 <= b2)
+ def test_compare_to_str(self):
+ self.assertEqual(b"abc" == "abc", True)
+ self.assertEqual(b"ab" != "abc", True)
+ self.assertEqual(b"ab" <= "abc", True)
+ self.assertEqual(b"ab" < "abc", True)
+ self.assertEqual(b"abc" >= "ab", True)
+ self.assertEqual(b"abc" > "ab", True)
+
+ self.assertEqual(b"abc" != "abc", False)
+ self.assertEqual(b"ab" == "abc", False)
+ self.assertEqual(b"ab" > "abc", False)
+ self.assertEqual(b"ab" >= "abc", False)
+ self.assertEqual(b"abc" < "ab", False)
+ self.assertEqual(b"abc" <= "ab", False)
+
def test_nohash(self):
self.assertRaises(TypeError, hash, bytes())