-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtest_listings.py
39 lines (24 loc) · 889 Bytes
/
test_listings.py
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
import pytest
from yalafi import parameters, parser, utils
preamble = '\\usepackage{listings}\n'
def get_plain(latex):
parms = parameters.Parameters()
p = parser.Parser(parms)
plain, nums = utils.get_txt_pos(p.parse(preamble + latex))
assert len(plain) == len(nums)
return plain
data_test_macros_latex = [
(r'A\lstinputlisting[opts]{file}B', 'A\n\nB'),
(r'A\lstset{opts}B', 'AB'),
]
@pytest.mark.parametrize('latex,plain_expected', data_test_macros_latex)
def test_macros_latex(latex, plain_expected):
plain = get_plain(latex)
assert plain == plain_expected
data_test_environments = [
(r'A\begin{lstlisting}[opts]xxx\end{lstlisting}B', 'A\n\n\nB'),
]
@pytest.mark.parametrize('latex,plain_expected', data_test_environments)
def test_environments(latex, plain_expected):
plain = get_plain(latex)
assert plain == plain_expected