| 178 | del os.environ['MAGIC'] |
| 179 | |
| 180 | def test_keep_going(self): |
| 181 | filename = os.path.join(self.TESTDATA_DIR, 'keep-going.jpg') |
| 182 | |
| 183 | m = magic.Magic(mime=True) |
| 184 | self.assertEqual(m.from_file(filename), 'image/jpeg') |
| 185 | |
| 186 | try: |
| 187 | # this will throw if you have an "old" version of the library |
| 188 | # I'm otherwise not sure how to query if keep_going is supported |
| 189 | magic.version() |
| 190 | m = magic.Magic(mime=True, keep_going=True) |
| 191 | self.assertEqual(m.from_file(filename), |
| 192 | 'image/jpeg\\012- application/octet-stream') |
| 193 | except NotImplementedError: |
| 194 | pass |
| 195 | |
| 196 | def test_rethrow(self): |
| 197 | old = magic.magic_buffer |