From be4cef70da48f0c945ce4fc4828613f5eb3f752b Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 10 May 2017 23:52:19 +0200 Subject: [PATCH] Fixing test/test_magic.py --- test/test_magic.py | 13 ++++++------- test/testdata/magic.pyc | Bin 0 -> 9170 bytes 2 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 test/testdata/magic.pyc diff --git a/test/test_magic.py b/test/test_magic.py index 6f4ed4e..a18fd5f 100755 --- a/test/test_magic.py +++ b/test/test_magic.py @@ -35,7 +35,6 @@ APPNAME = 'test_magic' LOG = logging.getLogger(APPNAME) - # ============================================================================= class MagicTest(LogtraceTestcase): @@ -60,7 +59,7 @@ class MagicTest(LogtraceTestcase): expected_value = (expected_value,) LOG.debug("Testing {!r}, expecting {!r}.".format(filename, expected_value)) - + for i in expected_value: with open(filename, 'rb') as f: buf_value = m.from_buffer(f.read()) @@ -71,7 +70,7 @@ class MagicTest(LogtraceTestcase): break else: self.assertTrue(False, "no match for " + repr(expected_value)) - + # ------------------------------------------------------------------------- def test_mime_types(self): @@ -84,7 +83,7 @@ class MagicTest(LogtraceTestcase): self.assert_values(m, { 'magic.pyc': 'application/octet-stream', 'test.pdf': 'application/pdf', - 'test.gz': 'application/gzip', + 'test.gz': ('application/gzip', 'application/x-gzip'), 'text.txt': 'text/plain', b'\xce\xbb'.decode('utf-8'): 'text/plain', b'\xce\xbb': 'text/plain', @@ -101,7 +100,7 @@ class MagicTest(LogtraceTestcase): os.environ['TZ'] = 'UTC' # To get the last modified date of test.gz in UTC try: self.assert_values(m, { - 'magic.pyc': 'python 2.4 byte-compiled', + 'magic.pyc': 'python 2.7 byte-compiled', 'test.pdf': 'PDF document, version 1.2', 'test.gz': ('gzip compressed data, was "test", from Unix, last modified: Sun Jun 29 01:32:52 2008', @@ -149,7 +148,7 @@ class MagicTest(LogtraceTestcase): LOG.debug("Testing {!r} - expecting {!r} - got {!r}.".format( filename, 'image/jpeg', result)) self.assertEqual(result, 'image/jpeg') - + m = magic.Magic(mime=True, keep_going=True) expected = ['image/jpeg', 'application/octet-stream'] result = m.from_file(filename) @@ -170,7 +169,7 @@ class MagicTest(LogtraceTestcase): def t(x,y): raise magic.MagicException("passthrough") magic.magic_buffer = t - + self.assertRaises(magic.MagicException, magic.from_buffer, "hello", True) finally: magic.magic_buffer = old diff --git a/test/testdata/magic.pyc b/test/testdata/magic.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2a54c8df9e75c402db14866f103d9b738ed5cbfc GIT binary patch literal 9170 zcmd5>-E$j9a_$h+mQ3LGcfY6P3iwOB;L4$PXgF5c$qOBvDzS zn-U$EbiE-l2wRY7mRrF}Y>lk?2kPbzE*mC!~Xez9qN(cf~leby~LGV;kt{-#Y;M08yQ!=h>S0w#+2OqS*MR_u&{=X*F|JE^Q zB+}FUgQKUzc_E8MiB2kSKal8@0%s+9M}cz^y{o{7WX0Bb@z0A{6mwpJB{6e66yXax zdQtp~l!Cdaql-EU*p6Nj|B{$lF_)%B0o&2b;$P;1=JM1iU^{w6{Ho5ajz+N#nT{q9 zK2V@0(P<_1iV|~G{A)Vp+IY%AF%{_)#h}N|0)ScX>8z_d>$>Uo$}Fm3fKbL(6q$g6#u3o+#Dm=HPN&Px5U4t2)Fhkpm{+eSNtDI zbVmG-C0Z2!6Nx?$|F%SD#s9HH=fuAw(TC!HDiNe}SE42He?tNNzRtpqxm~H;y?fVfr%BJv)39ZNUKn?~Nym+QgCxye-Ai#4 zsuDBc)=P`I$?_=7!y19=AZjmOsGNWNV8xA+*02Y*4&}(dlZ~;+0jN4%=;$E+qrge=SAT)P&K}wX4@Zy6{J-t5h~N!S=^H`6g)Y zCD9NZeja9S9&VeyGU>LvndgJ-cCFTl^UdMYYAfm0!p-4eP#fs9E0$rE_^cNYK51mniDB#wad25=rx3mPw4W}?xSQ!P#KtN z7(CI7QV?%_iNmb|DwZNj9VPn!RgQm0zE?vBBl^8VtLWehT|tqH*x4hRNoF>L?s=0V z1VP-7^B~9%V60~{>dzAQ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