diff options
| author | Adam Hupp <adam@hupp.org> | 2015-01-06 23:53:24 -0800 |
|---|---|---|
| committer | Adam Hupp <adam@hupp.org> | 2015-01-06 23:53:24 -0800 |
| commit | 209df6050372358f7334f65d5f68e2cb15fb2874 (patch) | |
| tree | f67a19fb1239832518ab6b09243dc413a0c96d01 | |
| parent | 831945b1a12e2e6643002213a2dd393d95c1c2f3 (diff) | |
| download | python-magic-209df6050372358f7334f65d5f68e2cb15fb2874.tar.gz | |
silence open file warnings in python 3
| -rw-r--r-- | test.py | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -13,9 +13,10 @@ class MagicTest(unittest.TestCase): except TypeError: filename = os.path.join(self.TESTDATA_DIR.encode('utf-8'), filename) - value = m.from_buffer(open(filename, 'rb').read()) - expected_value_bytes = expected_value.encode('utf-8') - self.assertEqual(value, expected_value_bytes) + with open(filename, 'rb') as f: + value = m.from_buffer(f.read()) + expected_value_bytes = expected_value.encode('utf-8') + self.assertEqual(value, expected_value_bytes) value = m.from_file(filename) self.assertEqual(value, expected_value_bytes) |
