22import re
33import shutil
44import sys
5- from typing import Union
5+ from typing import Union , cast
66
77# 3rd party
88import pytest
1111from coincidence .regressions import AdvancedFileRegressionFixture
1212from domdf_python_tools .paths import PathPlus
1313from domdf_python_tools .stringlist import StringList
14+ from domdf_python_tools .typing import PathLike
1415from jinja2 import Template
1516from pytest_regressions .common import check_text_files
17+ from sphinx .application import Sphinx
18+ from sphinx .builders import Builder
1619from sphinx_toolbox .testing import HTMLRegressionFixture
1720
1821
@@ -30,20 +33,20 @@ def doc_root(tmp_pathplus: PathPlus):
3033
3134@pytest .mark .usefixtures ("doc_root" )
3235@pytest .mark .sphinx ("html" , testroot = "test-html-section" )
33- def test_build_example (app ):
36+ def test_build_example (app : Sphinx ):
3437 app .build ()
3538 app .build ()
3639
3740
3841@pytest .mark .usefixtures ("doc_root" )
3942@pytest .mark .sphinx ("html" , testroot = "test-html-section" )
40- def test_html_output (app , html_regression : HTMLRegressionFixture ):
43+ def test_html_output (app : Sphinx , html_regression : HTMLRegressionFixture ):
4144
42- assert app .builder .name .lower () == "html"
45+ assert cast ( Builder , app .builder ) .name .lower () == "html"
4346
4447 app .build (force_all = True )
4548
46- output_file = PathPlus (app .outdir / "index.html" )
49+ output_file = PathPlus (app .outdir ) / "index.html"
4750 page = BeautifulSoup (output_file .read_text (), "html5lib" )
4851 html_regression .check (page , jinja2 = False )
4952
@@ -76,8 +79,7 @@ def check( # type: ignore
7679
7780 __tracebackhide__ = True
7881
79- def check_fn (obtained_filename , expected_filename ):
80- print (obtained_filename , expected_filename )
82+ def check_fn (obtained_filename : PathPlus , expected_filename : PathLike ):
8183 expected_filename = PathPlus (expected_filename )
8284
8385 template = Template (
@@ -123,11 +125,11 @@ def latex_regression(datadir, original_datadir, request) -> LaTeXRegressionFixtu
123125
124126@pytest .mark .usefixtures ("doc_root" )
125127@pytest .mark .sphinx ("latex" , testroot = "test-html-section" )
126- def test_latex_output (app , latex_regression : LaTeXRegressionFixture ):
128+ def test_latex_output (app : Sphinx , latex_regression : LaTeXRegressionFixture ):
127129
128- assert app .builder .name .lower () == "latex"
130+ assert cast ( Builder , app .builder ) .name .lower () == "latex"
129131
130132 app .build (force_all = True )
131133
132- output_file = PathPlus (app .outdir / "python.tex" )
134+ output_file = PathPlus (app .outdir ) / "python.tex"
133135 latex_regression .check (StringList (output_file .read_lines ()))
0 commit comments