mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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).
This commit is contained in:
parent
e94a37f3a1
commit
9e9dcd6d42
3 changed files with 14 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue