(self)
| 184 | self.assertEqual(f.read(size), data1) |
| 185 | |
| 186 | def test_io_on_closed_object(self): |
| 187 | # Test that I/O operations on closed GzipFile objects raise a |
| 188 | # ValueError, just like the corresponding functions on file objects. |
| 189 | |
| 190 | # Write to a file, open it for reading, then close it. |
| 191 | self.test_write() |
| 192 | f = gzip.GzipFile(self.filename, 'r') |
| 193 | fileobj = f.fileobj |
| 194 | self.assertFalse(fileobj.closed) |
| 195 | f.close() |
| 196 | self.assertTrue(fileobj.closed) |
| 197 | with self.assertRaises(ValueError): |
| 198 | f.read(1) |
| 199 | with self.assertRaises(ValueError): |
| 200 | f.seek(0) |
| 201 | with self.assertRaises(ValueError): |
| 202 | f.tell() |
| 203 | # Open the file for writing, then close it. |
| 204 | f = gzip.GzipFile(self.filename, 'w') |
| 205 | fileobj = f.fileobj |
| 206 | self.assertFalse(fileobj.closed) |
| 207 | f.close() |
| 208 | self.assertTrue(fileobj.closed) |
| 209 | with self.assertRaises(ValueError): |
| 210 | f.write(b'') |
| 211 | with self.assertRaises(ValueError): |
| 212 | f.flush() |
| 213 | |
| 214 | def test_append(self): |
| 215 | self.test_write() |
nothing calls this directly
no test coverage detected