diff options
author | Adam Hupp <adam@hupp.org> | 2016-03-21 21:43:19 -0700 |
---|---|---|
committer | Adam Hupp <adam@hupp.org> | 2016-03-21 21:43:19 -0700 |
commit | 74b53a66eb1b2f29cb5144aa19f2fb491c4cf4ec (patch) | |
tree | 430d3073e8b1ac9b94a38da64a67ddcac28a7f63 | |
parent | ded19e685a85a25ccc41ba7289326c2fb7bb9963 (diff) | |
download | python-magic-74b53a66eb1b2f29cb5144aa19f2fb491c4cf4ec.tar.gz |
hopefully fix tests on whatever travisci uses
-rwxr-xr-x | test/test.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/test/test.py b/test/test.py index 2561383..03914ff 100755 --- a/test/test.py +++ b/test/test.py @@ -1,4 +1,4 @@ -import os +import os, sys # for output which reports a local time os.environ['TZ'] = 'GMT' import shutil @@ -17,14 +17,22 @@ class MagicTest(unittest.TestCase): except TypeError: filename = os.path.join(self.TESTDATA_DIR.encode('utf-8'), filename) - 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) + + if type(expected_value) is not tuple: + expected_value = (expected_value,) - value = m.from_file(filename) - self.assertEqual(value, expected_value_bytes) - + for i in expected_value: + expected_value_bytes = i.encode('utf-8') + + with open(filename, 'rb') as f: + buf_value = m.from_buffer(f.read()) + + file_value = m.from_file(filename) + if buf_value == expected_value_bytes and file_value == expected_value_bytes: + break + else: + self.assertTrue(False, "no match for " + repr(expected_value)) + def test_mime_types(self): dest = os.path.join(MagicTest.TESTDATA_DIR, b'\xce\xbb'.decode('utf-8')) shutil.copyfile(os.path.join(MagicTest.TESTDATA_DIR, 'lambda'), dest) @@ -49,7 +57,8 @@ class MagicTest(unittest.TestCase): 'magic.pyc': 'python 2.4 byte-compiled', 'test.pdf': 'PDF document, version 1.2', 'test.gz': - 'gzip compressed data, was "test", last modified: Sun Jun 29 01:32:52 2008, from Unix', + ('gzip compressed data, was "test", from Unix, last modified: Sun Jun 29 01:32:52 2008', + 'gzip compressed data, was "test", last modified: Sun Jun 29 01:32:52 2008, from Unix'), 'text.txt': 'ASCII text', }) finally: |