Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
604e74c6
Commit
604e74c6
authored
Mar 27, 2017
by
Serhiy Storchaka
Committed by
Victor Stinner
Mar 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-20552: Use specific asserts in bytes tests (#790)
parent
b8a7daf0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
Lib/test/test_bytes.py
Lib/test/test_bytes.py
+15
-15
No files found.
Lib/test/test_bytes.py
View file @
604e74c6
...
...
@@ -1170,7 +1170,7 @@ class ByteArrayTest(BaseBytesTest, unittest.TestCase):
b += b"def"
self.assertEqual(b, b"abcdef")
self.assertEqual(b, b1)
self.assert
True(b is
b1)
self.assert
Is(b,
b1)
b += b"xyz"
self.assertEqual(b, b"abcdefxyz")
try:
...
...
@@ -1186,7 +1186,7 @@ class ByteArrayTest(BaseBytesTest, unittest.TestCase):
b *= 3
self.assertEqual(b, b"
abcabcabc
")
self.assertEqual(b, b1)
self.assert
True(b is
b1)
self.assert
Is(b,
b1)
def test_irepeat_1char(self):
b = bytearray(b"
x
")
...
...
@@ -1194,12 +1194,12 @@ class ByteArrayTest(BaseBytesTest, unittest.TestCase):
b *= 100
self.assertEqual(b, b"
x
"*100)
self.assertEqual(b, b1)
self.assert
True(b is
b1)
self.assert
Is(b,
b1)
def test_alloc(self):
b = bytearray()
alloc = b.__alloc__()
self.assert
True(alloc >=
0)
self.assert
GreaterEqual(alloc,
0)
seq = [alloc]
for i in range(100):
b += b"
x
"
...
...
@@ -1319,17 +1319,17 @@ class ByteArrayTest(BaseBytesTest, unittest.TestCase):
# Issue 4348. Make sure that operations that don't mutate the array
# copy the bytes.
b = bytearray(b'abc')
self.assert
False(b is
b.replace(b'abc', b'cde', 0))
self.assert
IsNot(b,
b.replace(b'abc', b'cde', 0))
t = bytearray([i for i in range(256)])
x = bytearray(b'')
self.assert
False(x is
x.translate(t))
self.assert
IsNot(x,
x.translate(t))
def test_partition_bytearray_doesnt_share_nullstring(self):
a, b, c = bytearray(b"
x
").partition(b"
y
")
self.assertEqual(b, b"")
self.assertEqual(c, b"")
self.assert
True(b is not
c)
self.assert
IsNot(b,
c)
b += b"
!
"
self.assertEqual(c, b"")
a, b, c = bytearray(b"
x
").partition(b"
y
")
...
...
@@ -1339,7 +1339,7 @@ class ByteArrayTest(BaseBytesTest, unittest.TestCase):
b, c, a = bytearray(b"
x
").rpartition(b"
y
")
self.assertEqual(b, b"")
self.assertEqual(c, b"")
self.assert
True(b is not
c)
self.assert
IsNot(b,
c)
b += b"
!
"
self.assertEqual(c, b"")
c, b, a = bytearray(b"
x
").rpartition(b"
y
")
...
...
@@ -1529,7 +1529,7 @@ class AssortedBytesTest(unittest.TestCase):
def test_return_self(self):
# bytearray.replace must always return a new bytearray
b = bytearray()
self.assert
False(b.replace(b'', b'') is
b)
self.assert
IsNot(b.replace(b'', b''),
b)
@unittest.skipUnless(sys.flags.bytes_warning,
"BytesWarning is needed for this test: use -bb option")
...
...
@@ -1588,14 +1588,14 @@ class BytearrayPEP3137Test(unittest.TestCase):
method = getattr(val, methname)
newval = method(3)
self.assertEqual(val, newval)
self.assert
True(val is not
newval,
self.assert
IsNot(val,
newval,
methname+' returned self on a mutable object')
for expr in ('val.split()[0]', 'val.rsplit()[0]',
'val.partition(b".")[0]', 'val.rpartition(b".")[2]',
'val.splitlines()[0]', 'val.replace(b"", b"")'):
newval = eval(expr)
self.assertEqual(val, newval)
self.assert
True(val is not
newval,
self.assert
IsNot(val,
newval,
expr+' returned val on a mutable object')
sep = self.marshal(b'')
newval = sep.join([val])
...
...
@@ -1634,7 +1634,7 @@ class SubclassTest:
self.assertTrue(_a <= _b)
self.assertTrue(_b >= _a)
self.assertTrue(_b > _a)
self.assert
True(_a is not
a)
self.assert
IsNot(_a,
a)
# test concat of subclass instances
self.assertEqual(a + b, _a + _b)
...
...
@@ -1650,12 +1650,12 @@ class SubclassTest:
# Make sure that it is of the appropriate type.
s1 = self.type2test(b"abcd")
s2 = self.basetype().join([s1])
self.assert
True(s1 is not
s2)
self.assert
True(type(s2) is
self.basetype, type(s2))
self.assert
IsNot(s1,
s2)
self.assert
Is(type(s2),
self.basetype, type(s2))
# Test reverse, calling join on subclass
s3 = s1.join([b"abcd"])
self.assert
True(type(s3) is
self.basetype)
self.assert
Is(type(s3),
self.basetype)
def test_pickle(self):
a = self.type2test(b"abcd")
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment