forked from FabriceSalvaire/CodeReview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_SyntaxHighlighter.py
More file actions
43 lines (27 loc) · 1.45 KB
/
test_SyntaxHighlighter.py
File metadata and controls
43 lines (27 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
####################################################################################################
import os
import unittest
from pygments.lexers import get_lexer_for_filename
####################################################################################################
from CodeReview.Diff.RawTextDocument import RawTextDocument
from CodeReview.Diff.SyntaxHighlighter import HighlightedText
####################################################################################################
class TestSyntaxHighlighter(unittest.TestCase):
###############################################
def test(self):
test_file_path = os.path.join(os.path.dirname(__file__), 'data', 'test_file1.py')
with open(test_file_path) as f:
text = f.read()
raw_text_document = RawTextDocument(text)
lexer = get_lexer_for_filename(test_file_path, stripnl=False)
highlighted_text = HighlightedText(raw_text_document, lexer)
for fragment in highlighted_text:
print(repr(fragment), '[' + raw_text_document.substring(fragment.slice) + ']')
####################################################################################################
if __name__ == '__main__':
unittest.main()
####################################################################################################
#
# End
#
####################################################################################################