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