Add a test to ensure null appending works fine.

This commit is contained in:
Jennifer Taylor 2021-10-20 22:07:25 +00:00
parent 9e53b4af0e
commit 43dfaaf220
1 changed files with 31 additions and 0 deletions

View File

@ -358,6 +358,37 @@ class TestFileBytes(unittest.TestCase):
with self.assertRaises(NotImplementedError):
fb[3:7] = b""
def test_append_null(self) -> None:
fb = FileBytes(io.BytesIO(b"0123456789"))
# Length check.
self.assertEqual(
len(fb),
10,
)
fb.append(b"")
self.assertEqual(
len(fb),
10,
)
# Verify modification stuck.
self.assertEqual(
fb[:],
b"0123456789",
)
# Verify that it gets serialized correctly.
fb.write_changes()
handle = fb.handle
if not isinstance(handle, io.BytesIO):
raise Exception("File handle changed type somehow!")
self.assertEqual(
handle.getvalue(),
b"0123456789",
)
def test_append_modify(self) -> None:
fb = FileBytes(io.BytesIO(b"0123456789"))