diff --git a/pydicts/tests/test_pylatex.py b/pydicts/tests/test_pylatex.py index eb9e851..7191696 100644 --- a/pydicts/tests/test_pylatex.py +++ b/pydicts/tests/test_pylatex.py @@ -1,27 +1,30 @@ -from pydicts import pylatex -from pylatex import Document, Section, Subsection -from pylatex.package import Package -from pylatex.utils import italic, NoEscape -lod=[ - {"year": 2022, "month": 1, "my_sum": 12}, - {"year": 2021, "month": 2, "my_sum": 123}, - {"year": 2019, "month": 5, "my_sum": 1}, - {"year": 2022, "month": 12, "my_sum": 12}, -] -def tests_pylatex_table_header(): +from shutil import which - doc = Document() - doc.packages.append(Package('xcolor')) +if which("pdflatex") is not None: + from pydicts import pylatex + from pylatex import Document, Section, Subsection + from pylatex.package import Package + from pylatex.utils import italic, NoEscape + lod=[ + {"year": 2022, "month": 1, "my_sum": 12}, + {"year": 2021, "month": 2, "my_sum": 123}, + {"year": 2019, "month": 5, "my_sum": 1}, + {"year": 2022, "month": 12, "my_sum": 12}, + ] + def tests_pylatex_table_header(): - with doc.create(Section('A section')): - doc.append('Some regular text and some ') - doc.append(italic('italic text. ')) + doc = Document() + doc.packages.append(Package('xcolor')) - with doc.create(Subsection('A subsection')): - doc.append('Also some crazy characters: $&#{}') - - doc.append(NoEscape("\\centering")) - pylatex.pylatex_table(doc, lod) - pylatex.pylatex_table(doc, []) - pylatex.pylatex_table_with_matched_values(doc, [2022, 2, 12], lod, code_="|l|c|r|", match_color="teal", unmatch_color="red") - doc.generate_pdf('test_pylatex_table_header', clean_tex=False) + with doc.create(Section('A section')): + doc.append('Some regular text and some ') + doc.append(italic('italic text. ')) + + with doc.create(Subsection('A subsection')): + doc.append('Also some crazy characters: $&#{}') + + doc.append(NoEscape("\\centering")) + pylatex.pylatex_table(doc, lod) + pylatex.pylatex_table(doc, []) + pylatex.pylatex_table_with_matched_values(doc, [2022, 2, 12], lod, code_="|l|c|r|", match_color="teal", unmatch_color="red") + doc.generate_pdf('test_pylatex_table_header', clean_tex=False)