summaryrefslogtreecommitdiff
path: root/test/test.py
diff options
context:
space:
mode:
authorAdam Hupp <adam@hupp.org>2018-08-16 08:09:17 -0700
committerAdam Hupp <adam@hupp.org>2018-08-16 08:09:17 -0700
commit41afcd5eab5203f8d4ac7d2ec2431db09aaeaf59 (patch)
tree163852136d524478d0cf6d88e5978da539712caf /test/test.py
parent9af943e0564c662f3e99cc4ee86363b8df1aff46 (diff)
downloadpython-magic-41afcd5eab5203f8d4ac7d2ec2431db09aaeaf59.tar.gz
Apply change from Corin-EU to allow tests to be run from any directory
Diffstat (limited to 'test/test.py')
-rwxr-xr-xtest/test.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/test/test.py b/test/test.py
index 2d8e861..044af95 100755
--- a/test/test.py
+++ b/test/test.py
@@ -9,7 +9,7 @@ import magic
class MagicTest(unittest.TestCase):
- TESTDATA_DIR = os.path.join(os.path.dirname(__file__), 'testdata')
+ TESTDATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testdata')
def assert_values(self, m, expected_values, buf_equals_file=True):
for filename, expected_value in expected_values.items():
@@ -34,10 +34,12 @@ class MagicTest(unittest.TestCase):
self.assertIn(value, expected_value)
def test_from_file_str_and_bytes(self):
+ filename = os.path.join(self.TESTDATA_DIR, "test.pdf")
+
self.assertEqual('application/pdf',
- magic.from_file("test/testdata/test.pdf", mime=True))
+ magic.from_file(filename, mime=True))
self.assertEqual('application/pdf',
- magic.from_file(b"test/testdata/test.pdf", mime=True))
+ magic.from_file(filename.encode('utf-8'), mime=True))
def test_from_buffer_str_and_bytes(self):
m = magic.Magic(mime=True)