コード例 #1
0
 def test_lambda(self):
     with open(os.path.join(PATH, 'files', b'\xce\xbb')) as f:
         b = f.read()
         type = hamish.from_buffer(b, mime=True)
         self.assertEqual(type, 'text/plain')
         type = hamish.from_buffer(b)
         self.assertEqual(type, 'ASCII text')
コード例 #2
0
 def test_pyc(self):
     with open(os.path.join(PATH, 'files', 'magic.pyc')) as f:
         b = f.read()
         type = hamish.from_buffer(b, mime=True)
         self.assertEqual(type, 'binary')
         type = hamish.from_buffer(b)
         self.assertEqual(type, 'python 2.4 byte-compiled')
コード例 #3
0
ファイル: test_hamish.py プロジェクト: douban/python-libmagic
 def test_lambda(self):
     with open(os.path.join(PATH, 'files', b'\xce\xbb')) as f:
         b = f.read()
         type = hamish.from_buffer(b, mime=True)
         self.assertEqual(type, 'text/plain')
         type = hamish.from_buffer(b)
         self.assertEqual(type, 'ASCII text')
コード例 #4
0
 def test_pdf(self):
     with open(os.path.join(PATH, 'files', 'test.pdf')) as f:
         b = f.read()
         type = hamish.from_buffer(b, mime=True)
         self.assertEqual(type, 'application/pdf')
         type = hamish.from_buffer(b)
         self.assertEqual(type, 'PDF document, version 1.2')
コード例 #5
0
ファイル: test_hamish.py プロジェクト: douban/python-libmagic
 def test_pyc(self):
     with open(os.path.join(PATH, 'files', 'magic.pyc')) as f:
         b = f.read()
         type = hamish.from_buffer(b, mime=True)
         self.assertEqual(type, 'binary')
         type = hamish.from_buffer(b)
         self.assertEqual(type, 'python 2.4 byte-compiled')
コード例 #6
0
ファイル: test_hamish.py プロジェクト: douban/python-libmagic
 def test_pdf(self):
     with open(os.path.join(PATH, 'files', 'test.pdf')) as f:
         b = f.read()
         type = hamish.from_buffer(b, mime=True)
         self.assertEqual(type, 'application/pdf')
         type = hamish.from_buffer(b)
         self.assertEqual(type, 'PDF document, version 1.2')
コード例 #7
0
ファイル: test_hamish.py プロジェクト: douban/python-libmagic
 def test_gz(self):
     with open(os.path.join(PATH, 'files', 'test.gz')) as f:
         b = f.read()
         type = hamish.from_buffer(b, mime=True)
         self.assertEqual(type, 'application/x-gzip')
         type = hamish.from_buffer(b)
         self.assertEqual(type, 'gzip compressed data, was "test", '
                          'last modified: Sun Jun 29 09:32:52 2008,'
                          ' from Unix')
コード例 #8
0
 def test_gz(self):
     with open(os.path.join(PATH, 'files', 'test.gz')) as f:
         b = f.read()
         type = hamish.from_buffer(b, mime=True)
         self.assertEqual(type, 'application/x-gzip')
         type = hamish.from_buffer(b)
         self.assertEqual(
             type, 'gzip compressed data, was "test", '
             'last modified: Sun Jun 29 09:32:52 2008,'
             ' from Unix')
コード例 #9
0
    def test_txt(self):
        with open(os.path.join(PATH, 'files', 'text.txt')) as f:
            b = f.read()
            type = hamish.from_buffer(b, mime=True)
            self.assertEqual(type, 'text/plain')
            type = hamish.from_buffer(b)
            self.assertEqual(type, 'ASCII text')

        with open(os.path.join(PATH, 'files', 'text-iso8859-1.txt')) as f:
            b = f.read()
            type = hamish.from_buffer(b, mime=True)
            self.assertEqual(type, 'text/plain')
            type = hamish.from_buffer(b)
            self.assertEqual(type, 'ISO-8859 text')
コード例 #10
0
ファイル: test_hamish.py プロジェクト: douban/python-libmagic
    def test_txt(self):
        with open(os.path.join(PATH, 'files', 'text.txt')) as f:
            b = f.read()
            type = hamish.from_buffer(b, mime=True)
            self.assertEqual(type, 'text/plain')
            type = hamish.from_buffer(b)
            self.assertEqual(type, 'ASCII text')

        with open(os.path.join(PATH, 'files', 'text-iso8859-1.txt')) as f:
            b = f.read()
            type = hamish.from_buffer(b, mime=True)
            self.assertEqual(type, 'text/plain')
            type = hamish.from_buffer(b)
            self.assertEqual(type, 'ISO-8859 text')