from pathlib import Path

from sphinx_testing import with_app


@with_app(buildername="latex", srcdir="doc_test/doc_build_latex")
def test_doc_build_latex(app, status, warning):
    app.build()

    latex_file = Path(app.outdir, "needstestdocs.tex")
    assert latex_file

    latex_content = latex_file.read_text()

    # Check table generated by Sphinxneeds has correct caption
    assert (
        "\\sphinxcaption{Table from sphinxneeds\\sphinxhyphen{}contrib \\textquotesingle"
        "{}needtable\\textquotesingle{} directive}" in latex_content
    )
