11import os
22# for output which reports a local time
33os .environ ['TZ' ] = 'GMT'
4-
4+ import shutil
55import os .path
66import unittest
77
@@ -26,15 +26,20 @@ def assert_values(self, m, expected_values):
2626 self .assertEqual (value , expected_value_bytes )
2727
2828 def test_mime_types (self ):
29- m = magic .Magic (mime = True )
30- self .assert_values (m , {
31- 'magic.pyc' : 'application/octet-stream' ,
32- 'test.pdf' : 'application/pdf' ,
33- 'test.gz' : 'application/gzip' ,
34- 'text.txt' : 'text/plain' ,
35- b'\xce \xbb ' .decode ('utf-8' ): 'text/plain' ,
36- b'\xce \xbb ' : 'text/plain' ,
37- })
29+ dest = os .path .join (MagicTest .TESTDATA_DIR , b'\xce \xbb ' .decode ('utf-8' ))
30+ shutil .copyfile (os .path .join (MagicTest .TESTDATA_DIR , 'lambda' ), dest )
31+ try :
32+ m = magic .Magic (mime = True )
33+ self .assert_values (m , {
34+ 'magic.pyc' : 'application/octet-stream' ,
35+ 'test.pdf' : 'application/pdf' ,
36+ 'test.gz' : 'application/gzip' ,
37+ 'text.txt' : 'text/plain' ,
38+ b'\xce \xbb ' .decode ('utf-8' ): 'text/plain' ,
39+ b'\xce \xbb ' : 'text/plain' ,
40+ })
41+ finally :
42+ os .unlink (dest )
3843
3944 def test_descriptions (self ):
4045 m = magic .Magic ()
0 commit comments