summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdam Hupp <adam@hupp.org>2021-10-04 14:46:37 -0700
committerAdam Hupp <adam@hupp.org>2021-10-04 16:04:28 -0700
commit7f7542fcbc192fef6e4939f4eb748e941a720b2c (patch)
tree8a1bebe0cfa08dd0148aa5120f9768cdfcfe50a1 /test
parent73bcc7482bf3e6d1f6a74a91bf9689b289a88910 (diff)
downloadpython-magic-7f7542fcbc192fef6e4939f4eb748e941a720b2c.tar.gz
Support os.PathLike types
See https://github.com/ahupp/python-magic/pull/251
Diffstat (limited to 'test')
-rwxr-xr-xtest/test.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/test.py b/test/test.py
index 0cd12fd..0c4621c 100755
--- a/test/test.py
+++ b/test/test.py
@@ -219,6 +219,14 @@ class MagicTest(unittest.TestCase):
with open(os.path.join(self.TESTDATA_DIR, 'name_use.jpg'), 'rb') as f:
m.from_buffer(f.read())
+ def test_pathlike(self):
+ if sys.version_info < (3, 6):
+ return
+ from pathlib import Path
+ path = Path(self.TESTDATA_DIR, "test.pdf")
+ m = magic.Magic(mime=True)
+ self.assertEqual('application/pdf', m.from_file(path))
+
if __name__ == '__main__':
unittest.main()