summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Hupp <adam@hupp.org>2015-01-06 23:53:24 -0800
committerAdam Hupp <adam@hupp.org>2015-01-06 23:53:24 -0800
commit209df6050372358f7334f65d5f68e2cb15fb2874 (patch)
treef67a19fb1239832518ab6b09243dc413a0c96d01
parent831945b1a12e2e6643002213a2dd393d95c1c2f3 (diff)
downloadpython-magic-209df6050372358f7334f65d5f68e2cb15fb2874.tar.gz
silence open file warnings in python 3
-rw-r--r--test.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/test.py b/test.py
index 3d922cd..f9c9c41 100644
--- a/test.py
+++ b/test.py
@@ -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)