diff options
author | Guido van Rossum <guido@python.org> | 2007-07-10 09:12:49 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-07-10 09:12:49 (GMT) |
commit | 4b5386f3982b86817cfe42dbedfaf0c04d0e443f (patch) | |
tree | c6c73336f78929f1ac300579d72ef82744375434 /Lib/test | |
parent | 2b6a97e69cd33ac7389b0e42c243b47e3d23f2fb (diff) | |
download | cpython-4b5386f3982b86817cfe42dbedfaf0c04d0e443f.zip cpython-4b5386f3982b86817cfe42dbedfaf0c04d0e443f.tar.gz cpython-4b5386f3982b86817cfe42dbedfaf0c04d0e443f.tar.bz2 |
Add proper tests for closed files to various I/O operations,
restoring a disabled test.
This was necessary to make test_pickle.py pass.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_file.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index adede2b..0764000 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -89,21 +89,31 @@ class AutoFileTests(unittest.TestCase): self.assert_(f.closed) def testMethods(self): - methods = ['fileno', 'flush', 'isatty', '__next__', 'read', 'readinto', - 'readline', 'readlines', 'seek', 'tell', 'truncate', - 'write', '__iter__'] - if sys.platform.startswith('atheos'): - methods.remove('truncate') + methods = [('fileno', ()), + ('flush', ()), + ('isatty', ()), + ('__next__', ()), + ('read', ()), + ('write', (b"",)), + ('readline', ()), + ('readlines', ()), + ('seek', (0,)), + ('tell', ()), + ('write', (b"",)), + ('writelines', ([],)), + ('__iter__', ()), + ] + if not sys.platform.startswith('atheos'): + methods.append(('truncate', ())) # __exit__ should close the file self.f.__exit__(None, None, None) self.assert_(self.f.closed) -## for methodname in methods: -## method = getattr(self.f, methodname) -## # should raise on closed file -## self.assertRaises(ValueError, method) -## self.assertRaises(ValueError, self.f.writelines, []) + for methodname, args in methods: + method = getattr(self.f, methodname) + # should raise on closed file + self.assertRaises(ValueError, method, *args) # file is closed, __exit__ shouldn't do anything self.assertEquals(self.f.__exit__(None, None, None), None) |