mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
For Make Benefit Glorious Nation of Backwards Compatibility,
bytes objects can now be compared to anything that supports the buffer API.
This commit is contained in:
parent
62cbc8a261
commit
343e97ff7f
2 changed files with 48 additions and 10 deletions
|
@ -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())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue