diff options
author | rmspeers <ryan@riverloopsecurity.com> | 2018-09-20 23:04:22 -0400 |
---|---|---|
committer | rmspeers <ryan@riverloopsecurity.com> | 2018-09-20 23:04:22 -0400 |
commit | 4514350cc363fde103e96cf53576061c116d3b67 (patch) | |
tree | bd745fe1e482fe7a4ae69cf15b8ac967a19d35c9 /test/test.py | |
parent | 33528682227836c6375c848bee8c767e42641fd8 (diff) | |
download | python-magic-4514350cc363fde103e96cf53576061c116d3b67.tar.gz |
Updated constructor to accept the raw flag and pass it to the underlying library. Helpful for cases where unicode chars exist in match results.
Diffstat (limited to 'test/test.py')
-rwxr-xr-x | test/test.py | 19 |
1 files changed, 19 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, { |