Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 3
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')
Ejemplo n.º 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')
Ejemplo n.º 5
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')
Ejemplo n.º 6
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')
Ejemplo n.º 7
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')
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 10
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')