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')
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')
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')
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')
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')
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')