Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(118)

Unified Diff: Lib/test/test_bytes.py

Issue 24467: bytearray pop and remove Buffer Over-read
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Objects/bytearrayobject.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_bytes.py Sun Jun 28 11:15:13 2015 -0400
+++ b/Lib/test/test_bytes.py Sun Jun 28 22:26:20 2015 +0300
@@ -1098,9 +1098,27 @@ class ByteArrayTest(BaseBytesTest, unitt
for i in range(100):
b += b"x"
alloc = b.__alloc__()
- self.assertTrue(alloc >= len(b))
+ self.assertGreater(alloc, len(b)) # including trailing null byte
if alloc not in seq:
seq.append(alloc)
+ print(seq)
+
+ def test_init_alloc(self):
+ b = bytearray()
+ def g():
+ for i in range(1, 100):
+ yield i
+ a = list(b)
+ self.assertEqual(a, list(range(1, len(a)+1)))
+ self.assertEqual(len(b), len(a))
+ self.assertLessEqual(len(b), i)
+ alloc = b.__alloc__()
+ self.assertGreater(alloc, len(b)) # including trailing null byte
+ b.__init__(g())
+ self.assertEqual(list(b), list(range(1, 100)))
+ self.assertEqual(len(b), 99)
+ alloc = b.__alloc__()
+ self.assertGreater(alloc, len(b))
def test_extend(self):
orig = b'hello'
« no previous file with comments | « no previous file | Objects/bytearrayobject.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+