Exemplo n.º 1
0
    def test_compiled_python_1(self):
        test_dir = self.extract_test_zip(
            'contenttype/compiled/python/compiled.zip')
        test_file = os.path.join(test_dir, 'command.pyc')
        assert get_filetype(test_file) == 'python 2.5 byte-compiled'
        assert not is_source(test_file)
        assert not is_text(test_file)
        expected_mime = (
            'application/octet-stream',
            # libmagic 5.39
            'text/x-bytecode.python',
        )
        assert get_mimetype_file(test_file) in expected_mime
        assert get_filetype_pygment(test_file) == ''

        test_file2 = os.path.join(test_dir, 'contenttype.pyc')
        assert is_binary(test_file2)
        assert get_pygments_lexer(test_file2) is None

        test_file3 = os.path.join(test_dir, 'contenttype.pyo')
        assert is_binary(test_file3)
        assert get_pygments_lexer(test_file3) is None

        test_file4 = os.path.join(test_dir, 'extract.pyc')
        assert get_filetype(test_file4) == 'python 2.5 byte-compiled'
        assert not is_source(test_file4)
        assert not is_text(test_file4)
        assert get_mimetype_file(test_file4) in expected_mime
        assert get_filetype_pygment(test_file4) == ''
Exemplo n.º 2
0
    def test_compiled_python_1(self):
        test_dir = self.extract_test_zip('contenttype/compiled/python/compiled.zip')
        test_file = os.path.join(test_dir, 'command.pyc')
        assert 'python 2.5 byte-compiled' == get_filetype(test_file)
        assert not is_source(test_file)
        assert not is_text(test_file)
        assert 'application/octet-stream' == get_mimetype_file(test_file)
        assert '' == get_filetype_pygment(test_file)

        test_file2 = os.path.join(test_dir, 'contenttype.pyc')
        assert is_binary(test_file2)
        assert get_pygments_lexer(test_file2) is None

        test_file3 = os.path.join(test_dir, 'contenttype.pyo')
        assert is_binary(test_file3)
        assert get_pygments_lexer(test_file3) is None

        test_file4 = os.path.join(test_dir, 'extract.pyc')
        assert 'python 2.5 byte-compiled' == get_filetype(test_file4)
        assert not is_source(test_file4)
        assert not is_text(test_file4)
        assert 'application/octet-stream' == get_mimetype_file(test_file4)
        assert '' == get_filetype_pygment(test_file4)
 def test_doc_html(self):
     assert not is_binary(self.get_test_loc('contenttype/doc/html/contenttype.html'))
     assert 'HTML' == get_pygments_lexer(self.get_test_loc('contenttype/doc/html/contenttype.html')).name
     assert not is_binary(self.get_test_loc('contenttype/doc/html/a.htm'))
 def test_compiled_python_3(self):
     test_dir = self.extract_test_zip('contenttype/compiled/python/compiled.zip')
     assert is_binary(os.path.join(test_dir, 'contenttype.pyo'))
     assert get_pygments_lexer(os.path.join(test_dir, 'contenttype.pyo')) is None
 def test_code_python_1(self):
     assert not is_binary(self.get_test_loc('contenttype/code/python/contenttype.py'))
     assert 'Python' == get_pygments_lexer(self.get_test_loc('contenttype/code/python/contenttype.py')).name
 def test_code_java_1(self):
     assert not is_binary(self.get_test_loc('contenttype/code/java/contenttype.java'))
     assert 'Java' == get_pygments_lexer(self.get_test_loc('contenttype/code/java/contenttype.java')).name
Exemplo n.º 7
0
 def test_doc_html_4(self):
     test_file = self.get_test_loc('contenttype/doc/html/a.htm')
     assert not is_binary(test_file)
     assert not is_binary(test_file)
     assert 'HTML' == get_pygments_lexer(test_file).name
Exemplo n.º 8
0
 def test_code_python_1(self):
     test_file = self.get_test_loc('contenttype/code/python/contenttype.py')
     assert not is_binary(test_file)
     assert 'Python' == get_pygments_lexer(test_file).name
Exemplo n.º 9
0
 def test_code_java_1(self):
     test_file = self.get_test_loc('contenttype/code/java/contenttype.java')
     assert not is_binary(test_file)
     assert 'Java' == get_pygments_lexer(test_file).name