diff options
Diffstat (limited to 'tests/support')
-rw-r--r-- | tests/support/empty.py | 0 | ||||
-rw-r--r-- | tests/support/html_formatter.py | 5 | ||||
-rw-r--r-- | tests/support/python_lexer.py | 11 | ||||
-rw-r--r-- | tests/support/structural_diff.py | 37 | ||||
-rw-r--r-- | tests/support/tags | 36 |
5 files changed, 89 insertions, 0 deletions
diff --git a/tests/support/empty.py b/tests/support/empty.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/support/empty.py diff --git a/tests/support/html_formatter.py b/tests/support/html_formatter.py new file mode 100644 index 0000000..5f04fd5 --- /dev/null +++ b/tests/support/html_formatter.py @@ -0,0 +1,5 @@ +from pygments.formatters import HtmlFormatter + + +class HtmlFormatterWrapper(HtmlFormatter): + name = 'HtmlWrapper' diff --git a/tests/support/python_lexer.py b/tests/support/python_lexer.py new file mode 100644 index 0000000..78d9c4a --- /dev/null +++ b/tests/support/python_lexer.py @@ -0,0 +1,11 @@ +# pygments.lexers.python (as CustomLexer) for test_cmdline.py + +from pygments.lexers import PythonLexer + + +class CustomLexer(PythonLexer): + name = 'PythonLexerWrapper' + + +class LexerWrapper(CustomLexer): + name = 'PythonLexerWrapperWrapper' diff --git a/tests/support/structural_diff.py b/tests/support/structural_diff.py new file mode 100644 index 0000000..cea27d1 --- /dev/null +++ b/tests/support/structural_diff.py @@ -0,0 +1,37 @@ +import html.parser + + +class Parser(html.parser.HTMLParser): + def __init__(self): + super().__init__() + self._stream = [] + + def handle_starttag(self, tag, attrs): + attrs = sorted(attrs, key=lambda x: x[0]) + attrs = '|'.join([k[0] + ':' + k[1] for k in attrs]) + self._stream.append(('<', tag, attrs)) + + def handle_endtag(self, tag): + self._stream.append(('>', tag, '')) + + def handle_data(self, data): + self._stream.append(('_', data, '')) + + @property + def stream(self): + return self._stream + + +def _serialize(t): + parser = Parser() + parser.feed(t) + return parser.stream + + +def structural_diff(a, b): + """Check if there is a structural difference between two HTML files.""" + a_s = _serialize(a) + b_s = _serialize(b) + + for e, f in zip(a_s, b_s): + assert e == f, f'Expected: {e}, found: {f}' diff --git a/tests/support/tags b/tests/support/tags new file mode 100644 index 0000000..193779f --- /dev/null +++ b/tests/support/tags @@ -0,0 +1,36 @@ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ +!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ +!_TAG_PROGRAM_NAME Exuberant Ctags // +!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ +!_TAG_PROGRAM_VERSION 5.8 // +HtmlFormatter test_html_formatter.py 19;" i +HtmlFormatterTest test_html_formatter.py 34;" c +NullFormatter test_html_formatter.py 19;" i +PythonLexer test_html_formatter.py 18;" i +StringIO test_html_formatter.py 13;" i +dirname test_html_formatter.py 16;" i +escape_html test_html_formatter.py 20;" i +fp test_html_formatter.py 27;" v +inspect test_html_formatter.py 15;" i +isfile test_html_formatter.py 16;" i +join test_html_formatter.py 16;" i +os test_html_formatter.py 10;" i +re test_html_formatter.py 11;" i +subprocess test_html_formatter.py 125;" i +support test_html_formatter.py 23;" i +tempfile test_html_formatter.py 14;" i +test_all_options test_html_formatter.py 72;" m class:HtmlFormatterTest +test_correct_output test_html_formatter.py 35;" m class:HtmlFormatterTest +test_ctags test_html_formatter.py 165;" m class:HtmlFormatterTest +test_external_css test_html_formatter.py 48;" m class:HtmlFormatterTest +test_get_style_defs test_html_formatter.py 141;" m class:HtmlFormatterTest +test_lineanchors test_html_formatter.py 98;" m class:HtmlFormatterTest +test_lineanchors_with_startnum test_html_formatter.py 106;" m class:HtmlFormatterTest +test_linenos test_html_formatter.py 82;" m class:HtmlFormatterTest +test_linenos_with_startnum test_html_formatter.py 90;" m class:HtmlFormatterTest +test_unicode_options test_html_formatter.py 155;" m class:HtmlFormatterTest +test_valid_output test_html_formatter.py 114;" m class:HtmlFormatterTest +tokensource test_html_formatter.py 29;" v +uni_open test_html_formatter.py 21;" i +unittest test_html_formatter.py 12;" i |