Skip to content

Commit

Permalink
add minimal (skipped) tests to test_file.py
Browse files Browse the repository at this point in the history
  • Loading branch information
picnixz committed Jun 20, 2024
1 parent d47d88f commit a8e7b7f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Lib/test/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ def testReadinto_text(self):
if hasattr(self.f, "readinto"):
self.assertRaises(TypeError, self.f.readinto, a)

def test_backread_into(self):
self.skipTest("TODO")

def test_backread_into_text(self):
self.skipTest("TODO (should not be supported, for now)")

def testWritelinesUserList(self):
# verify writelines with instance sequence
l = UserList([b'1', b'2'])
Expand Down Expand Up @@ -121,6 +127,12 @@ def testMethods(self):
# should raise on closed file
self.assertRaises(ValueError, method, *args)

# TODO(picnixz): NotImplementedError -> ValueError when implemented in C
for methodname in ('backread', 'backreadline'):
method = getattr(self.f, methodname)
with self.subTest(method=methodname):
self.assertRaises((NotImplementedError, ValueError), method)

# file is closed, __exit__ shouldn't do anything
self.assertEqual(self.f.__exit__(None, None, None), None)
# it must also return None if an exception was given
Expand All @@ -132,6 +144,10 @@ def testMethods(self):
def testReadWhenWriting(self):
self.assertRaises(OSError, self.f.read)

def testBackReadWhenWriting(self):
# this delegates to the abstract BufferedIOBase.backread()
self.assertRaises(io.UnsupportedOperation, self.f.backread)

class CAutoFileTests(AutoFileTests, unittest.TestCase):
open = io.open

Expand Down Expand Up @@ -341,6 +357,11 @@ def testIteration(self):
finally:
f.close()

def test_reverse_iteration(self):
# Test the complex interaction when mixing file-reverse iteration
# and the various backread* methods.
self.skipTest("TODO")

class COtherFileTests(OtherFileTests, unittest.TestCase):
open = io.open

Expand Down

0 comments on commit a8e7b7f

Please sign in to comment.