summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdam Hupp <adam@hupp.org>2018-10-08 21:01:56 -0700
committerGitHub <noreply@github.com>2018-10-08 21:01:56 -0700
commitd9ffadd4ab85553937389f10b39e1da1f5ed583e (patch)
tree94cc62f10d29f93141dc98238c40ae53159e7703 /test
parent33528682227836c6375c848bee8c767e42641fd8 (diff)
parent9af629af1709863b36b716ec344adf74725ac692 (diff)
downloadpython-magic-d9ffadd4ab85553937389f10b39e1da1f5ed583e.tar.gz
Merge pull request #183 from rmspeers/feature/raw-flag
Flag Addition: Raw
Diffstat (limited to 'test')
-rwxr-xr-xtest/test.py19
-rw-r--r--test/testdata/pgpunicode1
2 files changed, 20 insertions, 0 deletions
diff --git a/test/test.py b/test/test.py
index ab29def..0f3aac2 100755
--- a/test/test.py
+++ b/test/test.py
@@ -84,6 +84,25 @@ class MagicTest(unittest.TestCase):
finally:
del os.environ['TZ']
+ def test_unicode_result_nonraw(self):
+ m = magic.Magic(raw=False)
+ src = os.path.join(MagicTest.TESTDATA_DIR, 'pgpunicode')
+ result = m.from_file(src)
+ # NOTE: This check is added as otherwise some magic files don't identify the test case as a PGP key.
+ if 'PGP' in result:
+ assert r"PGP\011Secret Sub-key -" == result
+ else:
+ raise unittest.SkipTest("Magic file doesn't return expected type.")
+
+ def test_unicode_result_raw(self):
+ m = magic.Magic(raw=True)
+ src = os.path.join(MagicTest.TESTDATA_DIR, 'pgpunicode')
+ result = m.from_file(src)
+ if 'PGP' in result:
+ assert b'PGP\tSecret Sub-key -' == result.encode('utf-8')
+ else:
+ raise unittest.SkipTest("Magic file doesn't return expected type.")
+
def test_mime_encodings(self):
m = magic.Magic(mime_encoding=True)
self.assert_values(m, {
diff --git a/test/testdata/pgpunicode b/test/testdata/pgpunicode
new file mode 100644
index 0000000..a44a36b
--- /dev/null
+++ b/test/testdata/pgpunicode
@@ -0,0 +1 @@
+qʐ \ No newline at end of file