-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathtest_build.py
105 lines (77 loc) · 3.97 KB
/
test_build.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
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
"""Test sphinxcontrib.video extension."""
import pytest
from bs4 import BeautifulSoup, formatter
fmt = formatter.HTMLFormatter(indent=2, void_element_close_prefix=" /")
@pytest.mark.sphinx("latex", testroot="video")
def test_video_latex(app, status, warning, file_regression):
"""Build a latex output (unsuported)."""
app.builder.build_all()
assert "unsupported output format (node skipped)" in warning.getvalue()
@pytest.mark.sphinx(testroot="video")
def test_video(app, status, warning, file_regression):
"""Build a video without options."""
app.builder.build_all()
html = (app.outdir / "mp4.html").read_text(encoding="utf8")
html = BeautifulSoup(html, "html.parser")
video = html.select("video")[0].prettify(formatter=fmt)
file_regression.check(video, basename="video_no_options", extension=".html")
@pytest.mark.sphinx(testroot="video")
def test_video_options(app, status, warning, file_regression):
"""Build a video without all options activated."""
app.builder.build_all()
html = (app.outdir / "mp4_options.html").read_text(encoding="utf8")
html = BeautifulSoup(html, "html.parser")
video = html.select("video")[0].prettify(formatter=fmt)
file_regression.check(video, basename="video_options", extension=".html")
@pytest.mark.sphinx(testroot="video-warnings")
def test_wrong_format(app, status, warning, file_regression):
"""Build a video with a non supported format and check the error message."""
app.builder.build_all()
assert (
'The provided file type (".mkv") is not a supported format. defaulting to ""'
in warning.getvalue()
)
# test the video is still existing
html = (app.outdir / "wrong_format.html").read_text(encoding="utf8")
html = BeautifulSoup(html, "html.parser")
video = html.select("video")[0].prettify(formatter=fmt)
file_regression.check(video, basename="video_wrong_format", extension=".html")
@pytest.mark.sphinx(testroot="video-warnings")
def test_wrong_height(app, status, warning, file_regression):
"""Build a video with badly designed option and check it's ignored."""
app.builder.build_all()
# test the video is still existing
html = (app.outdir / "wrong_height.html").read_text(encoding="utf8")
html = BeautifulSoup(html, "html.parser")
video = html.select("video")[0].prettify(formatter=fmt)
file_regression.check(video, basename="video_no_options", extension=".html")
@pytest.mark.sphinx(testroot="video-warnings")
def test_wrong_width(app, status, warning, file_regression):
"""Build a video with badly designed option and check it's ignored."""
app.builder.build_all()
# test the video is still existing
html = (app.outdir / "wrong_width.html").read_text(encoding="utf8")
html = BeautifulSoup(html, "html.parser")
video = html.select("video")[0].prettify(formatter=fmt)
file_regression.check(video, basename="video_no_options", extension=".html")
@pytest.mark.sphinx(testroot="video-warnings")
def test_wrong_preload(app, status, warning, file_regression):
"""Build a video with badly designed option and check it's ignored."""
app.builder.build_all()
# test the video is still existing
html = (app.outdir / "wrong_preload.html").read_text(encoding="utf8")
html = BeautifulSoup(html, "html.parser")
video = html.select("video")[0].prettify(formatter=fmt)
file_regression.check(video, basename="video_no_options", extension=".html")
@pytest.mark.sphinx(testroot="video-secondary")
def test_video_force_secondary(app, status, warning, file_regression):
"""Build a latex output (unsuported)."""
app.builder.build_all()
assert (
'A secondary source should be provided for "_static/video.mp4"'
in warning.getvalue()
)
html = (app.outdir / "mp4_secondary.html").read_text(encoding="utf8")
html = BeautifulSoup(html, "html.parser")
video = html.select("video")[0].prettify(formatter=fmt)
file_regression.check(video, basename="video_secondary", extension=".html")