77 :license: BSD, see LICENSE for details.
88"""
99
10- import random
11- from io import StringIO ,BytesIO
1210from os import path
1311
1412import pytest
1513
16- from pygments import lexers , formatters , lex , format
14+ from pygments import lexers
1715
1816TESTDIR = path .dirname (path .abspath (__file__ ))
1917
18+
2019def _guess_lexer_for_file (filename ):
21- return lexers .guess_lexer (open (path .join (TESTDIR ,'examplefiles' ,filename ),'r' ,encoding = 'utf-8' ).read ())
20+ return lexers .guess_lexer (open (path .join (TESTDIR ,'examplefiles' ,filename ),
21+ 'r' ,encoding = 'utf-8' ).read ())
22+
2223
2324@pytest .mark .skip (reason = "This is identified as T-SQL" )
2425def test_guess_lexer_fsharp ():
25- l = _guess_lexer_for_file ('Deflate.rs' )
26- assert l .__class__ .__name__ == 'FSharpLexer'
26+ lx = _guess_lexer_for_file ('Deflate.rs' )
27+ assert lx .__class__ .__name__ == 'FSharpLexer'
28+
2729
2830def test_guess_lexer_brainfuck ():
29- l = lexers .guess_lexer (">>[-]<<[->>+<<]" )
30- assert l .__class__ .__name__ == 'BrainfuckLexer'
31+ lx = lexers .guess_lexer (">>[-]<<[->>+<<]" )
32+ assert lx .__class__ .__name__ == 'BrainfuckLexer'
33+
3134
3235def test_guess_lexer_singularity ():
33- l = _guess_lexer_for_file ('Singularity' )
34- assert l .__class__ .__name__ == 'SingularityLexer'
36+ lx = _guess_lexer_for_file ('Singularity' )
37+ assert lx .__class__ .__name__ == 'SingularityLexer'
38+
3539
3640@pytest .mark .skip (reason = "This is identified as MIME" )
3741def test_guess_lexer_matlab ():
38- l = lexers .guess_lexer (r'A \ B' )
39- assert l .__class__ .__name__ == 'OctaveLexer'
42+ lx = lexers .guess_lexer (r'A \ B' )
43+ assert lx .__class__ .__name__ == 'OctaveLexer'
44+
4045
4146@pytest .mark .skip (reason = "This is identified as Python" )
4247def test_guess_lexer_hybris ():
43- l = _guess_lexer_for_file ('hybris_File.hy' )
44- assert l .__class__ .__name__ == 'HybrisLexer'
48+ lx = _guess_lexer_for_file ('hybris_File.hy' )
49+ assert lx .__class__ .__name__ == 'HybrisLexer'
50+
4551
4652def test_guess_lexer_forth ():
47- l = _guess_lexer_for_file ('demo.frt' )
48- assert l .__class__ .__name__ == 'ForthLexer'
53+ lx = _guess_lexer_for_file ('demo.frt' )
54+ assert lx .__class__ .__name__ == 'ForthLexer'
55+
4956
5057def test_guess_lexer_modula2 ():
51- l = _guess_lexer_for_file ('modula2_test_cases.def' )
52- assert l .__class__ .__name__ == 'Modula2Lexer'
58+ lx = _guess_lexer_for_file ('modula2_test_cases.def' )
59+ assert lx .__class__ .__name__ == 'Modula2Lexer'
60+
5361
5462def test_guess_lexer_unicon ():
55- l = _guess_lexer_for_file ('example.icn' )
56- assert l .__class__ .__name__ == 'UcodeLexer'
63+ lx = _guess_lexer_for_file ('example.icn' )
64+ assert lx .__class__ .__name__ == 'UcodeLexer'
65+
5766
5867def test_guess_lexer_ezhil ():
59- l = _guess_lexer_for_file ('ezhil_primefactors.n' )
60- assert l .__class__ .__name__ == 'EzhilLexer'
68+ lx = _guess_lexer_for_file ('ezhil_primefactors.n' )
69+ assert lx .__class__ .__name__ == 'EzhilLexer'