forked from sio2project/sinol-make
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_integration.py
More file actions
137 lines (118 loc) · 4.29 KB
/
test_integration.py
File metadata and controls
137 lines (118 loc) · 4.29 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import os
import glob
import pytest
from sinol_make import configure_parsers
from sinol_make.commands.doc import Command
from sinol_make.helpers import paths
from tests.fixtures import create_package
from tests import util
@pytest.mark.parametrize("create_package", [util.get_doc_package_path()], indirect=True)
def test_simple(capsys, create_package):
"""
Test `doc` command with no parameters.
"""
parser = configure_parsers()
args = parser.parse_args(["doc"])
command = Command()
command.run(args)
out = capsys.readouterr().out
assert "Compilation was successful for all files." in out
for pattern in command.LOG_PATTERNS:
assert glob.glob(os.path.join(os.getcwd(), 'doc', pattern)) == []
@pytest.mark.parametrize("create_package", [util.get_doc_package_path()], indirect=True)
def test_argument(capsys, create_package):
"""
Test `doc` command with specified file.
"""
parser = configure_parsers()
args = parser.parse_args(["doc", "doc/doczad.tex"])
command = Command()
command.run(args)
out = capsys.readouterr().out
assert "Compilation was successful for all files." in out
assert "pdflatex" in out # In auto mode this command will use pdflatex
logs_exist = False
logs_dir = paths.get_cache_path('doc_logs')
for pattern in command.LOG_PATTERNS:
assert glob.glob(os.path.join(os.getcwd(), 'doc', pattern)) == []
logs_exist = logs_exist | (glob.glob(os.path.join(logs_dir, pattern)) != [])
assert logs_exist
def run_doc(capsys, command_args, expected, not_expected):
"""
Run doc command
"""
parser = configure_parsers()
args = parser.parse_args(command_args)
command = Command()
command.run(args)
out = capsys.readouterr().out
assert "Compilation was successful for all files." in out
assert expected in out
assert not_expected not in out
@pytest.mark.parametrize("create_package", [util.get_ps_doc_package_path()], indirect=True)
def test_ps_images(capsys, create_package):
"""
Test `doc` command with ps images.
"""
run_doc(
capsys=capsys,
command_args=["doc"],
expected="latex to dvi", # In auto mode this command should use latex and dvipdf
not_expected="pdflatex" # and shouldn't use pdflatex for any compilation
)
@pytest.mark.parametrize("create_package", [util.get_ps_doc_package_path()], indirect=True)
def test_compilation_mode(capsys, create_package):
"""
Test `doc` with compilation mode directly specified.
"""
run_doc(
capsys=capsys,
command_args=["doc", "doc/doczad.tex", "--latex-compiler", "pdflatex"],
expected="pdflatex",
not_expected="latex to dvi"
)
@pytest.mark.parametrize("create_package", [util.get_doc_package_path()], indirect=True)
def test_compilation_mode_2(capsys, create_package):
"""
Test `doc` with compilation mode directly specified.
"""
run_doc(
capsys=capsys,
command_args=["doc", "doc/doczad.tex", "--latex-compiler", "latex_dvi"],
expected="latex to dvi",
not_expected="pdflatex"
)
@pytest.mark.parametrize("create_package", [util.get_doc_package_path()], indirect=True)
def test_compilation_mode_3(capsys, create_package):
"""
Test `doc` with compilation mode directly specified.
"""
run_doc(
capsys=capsys,
command_args=["doc", "doc/doczad.tex", "--latex-compiler", "lualatex"],
expected="lualatex",
not_expected="pdflatex"
)
@pytest.mark.parametrize("create_package", [util.get_luadoc_package_path()], indirect=True)
def test_compilation_mode_config(capsys, create_package):
"""
Test `doc` with compilation mode specified in the configuration file.
"""
run_doc(
capsys=capsys,
command_args=["doc"],
expected="lualatex",
not_expected="pdflatex"
)
@pytest.mark.parametrize("create_package", [util.get_luadoc_package_path()], indirect=True)
def test_compilation_mode_config_override(capsys, create_package):
"""
Test `doc` with compilation mode specified in the configuration file, and
then overridden on the command-line.
"""
run_doc(
capsys=capsys,
command_args=["doc", "--latex-compiler", "pdflatex"],
expected="pdflatex",
not_expected="lualatex"
)