Skip to content

Commit 41afcd5

Browse files
committed
Apply change from Corin-EU to allow tests to be run from any directory
1 parent 9af943e commit 41afcd5

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

test/test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class MagicTest(unittest.TestCase):
12-
TESTDATA_DIR = os.path.join(os.path.dirname(__file__), 'testdata')
12+
TESTDATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testdata')
1313

1414
def assert_values(self, m, expected_values, buf_equals_file=True):
1515
for filename, expected_value in expected_values.items():
@@ -34,10 +34,12 @@ def assert_values(self, m, expected_values, buf_equals_file=True):
3434
self.assertIn(value, expected_value)
3535

3636
def test_from_file_str_and_bytes(self):
37+
filename = os.path.join(self.TESTDATA_DIR, "test.pdf")
38+
3739
self.assertEqual('application/pdf',
38-
magic.from_file("test/testdata/test.pdf", mime=True))
40+
magic.from_file(filename, mime=True))
3941
self.assertEqual('application/pdf',
40-
magic.from_file(b"test/testdata/test.pdf", mime=True))
42+
magic.from_file(filename.encode('utf-8'), mime=True))
4143

4244
def test_from_buffer_str_and_bytes(self):
4345
m = magic.Magic(mime=True)

0 commit comments

Comments
 (0)