Skip to content

Instantly share code, notes, and snippets.

@gandarez
Created January 21, 2021 00:10
Show Gist options
  • Save gandarez/a5ec5888eb722ca0f13b5a778361328d to your computer and use it in GitHub Desktop.
Save gandarez/a5ec5888eb722ca0f13b5a778361328d to your computer and use it in GitHub Desktop.
Test analyse_text for MIMELexer
import os
import pytest
from pygments.lexers.mime import MIMELexer
@pytest.fixture(scope="module")
def lexer():
yield MIMELexer()
def _example_file_path(filename):
return os.path.join(os.path.dirname(__file__), 'examplefiles', filename)
def test_mime_analyse_text(lexer):
with open(_example_file_path("MIME_example.eml"), 'rb') as fp:
text = fp.read().decode('utf-8')
res = lexer.analyse_text(text)
assert res == 1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment