diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2010-10-06 21:29:56 (GMT) | 
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-10-06 21:29:56 (GMT) | 
| commit | e3900542e4c90c66a5a89a38a3c19dd2cf117251 (patch) | |
| tree | 88f58158eae1d5002cd4dc9c37a06aa3b7604460 /Lib/test/test_gzip.py | |
| parent | e5e6bc68f9c9aa127ea7ae390b1a0a7005b5d805 (diff) | |
| download | cpython-e3900542e4c90c66a5a89a38a3c19dd2cf117251.zip cpython-e3900542e4c90c66a5a89a38a3c19dd2cf117251.tar.gz cpython-e3900542e4c90c66a5a89a38a3c19dd2cf117251.tar.bz2 | |
Merged revisions 85291 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
  r85291 | antoine.pitrou | 2010-10-06 23:21:18 +0200 (mer., 06 oct. 2010) | 4 lines
  Issue #9759: GzipFile now raises ValueError when an operation is attempted
  after the file is closed.  Patch by Jeffrey Finkelstein.
........
Diffstat (limited to 'Lib/test/test_gzip.py')
| -rw-r--r-- | Lib/test/test_gzip.py | 22 | 
1 files changed, 22 insertions, 0 deletions
| diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index d928635..a4a7e24 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -51,6 +51,28 @@ class TestGzip(unittest.TestCase):          f = gzip.GzipFile(self.filename, 'r') ; d = f.read() ; f.close()          self.assertEqual(d, data1*50) +    def test_io_on_closed_object(self): +        # Test that I/O operations on closed GzipFile objects raise a +        # ValueError, just like the corresponding functions on file objects. + +        # Write to a file, open it for reading, then close it. +        self.test_write() +        f = gzip.GzipFile(self.filename, 'r') +        f.close() +        with self.assertRaises(ValueError): +            f.read(1) +        with self.assertRaises(ValueError): +            f.seek(0) +        with self.assertRaises(ValueError): +            f.tell() +        # Open the file for writing, then close it. +        f = gzip.GzipFile(self.filename, 'w') +        f.close() +        with self.assertRaises(ValueError): +            f.write(b'') +        with self.assertRaises(ValueError): +            f.flush() +      def test_append(self):          self.test_write()          # Append to the previous file | 
