Skip to content

Commit

Permalink
Add wbplus file test
Browse files Browse the repository at this point in the history
  • Loading branch information
BCSharp committed Dec 10, 2024
1 parent cc92235 commit 380ab36
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,23 @@ def test_opener_uncallable(self):

self.assertRaises(TypeError, open, "", "r", opener=uncallable_opener)

def test_open_wbplus(self):
with open(self.temp_file, "wb+") as f:
f.write(b"abc")
f.seek(0)
self.assertEqual(f.read(2), b"ab")
f.write(b"def")
self.assertEqual(f.read(2), b"")
f.seek(0)
self.assertEqual(f.read(6), b"abdef")
f.seek(0)
self.assertEqual(f.read(2), b"ab")
f.fileno() # does not move the file pointer
self.assertEqual(f.read(2), b"de")
f.write(b"z")
f.seek(0)
self.assertEqual(f.read(), b"abdez")

def test_open_abplus(self):
with open(self.temp_file, "ab+") as f:
f.write(b"abc")
Expand Down

0 comments on commit 380ab36

Please sign in to comment.