def test_from_file_unknown_lexer(): fh, path = tempfile.mkstemp("example.nosuchtype") try: os.write(fh, b"import this\n") syntax = Syntax.from_path(path) assert syntax.lexer_name == "default" assert syntax.code == "import this\n" finally: os.remove(path)
def test_from_file(): fh, path = tempfile.mkstemp("example.py") try: os.write(fh, b"import this\n") syntax = Syntax.from_path(path) assert syntax.lexer_name == "Python" assert syntax.code == "import this\n" finally: os.remove(path)