]> Frank Brehm's Git Trees - pixelpark/trace-maillog.git/commitdiff
Fixing test/test_magic.py
authorFrank Brehm <frank@brehm-online.com>
Wed, 10 May 2017 21:52:19 +0000 (23:52 +0200)
committerFrank Brehm <frank@brehm-online.com>
Wed, 10 May 2017 21:52:19 +0000 (23:52 +0200)
test/test_magic.py
test/testdata/magic.pyc [new file with mode: 0644]

index 6f4ed4e8118298e783eb26b78e81a338f80ee0d2..a18fd5f1bdb19a4db4da451c3cd0bbad337f11fb 100755 (executable)
@@ -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 (file)
index 0000000..2a54c8d
Binary files /dev/null and b/test/testdata/magic.pyc differ