From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- share/extensions/tests/test_pdflatex.py | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 share/extensions/tests/test_pdflatex.py (limited to 'share/extensions/tests/test_pdflatex.py') diff --git a/share/extensions/tests/test_pdflatex.py b/share/extensions/tests/test_pdflatex.py new file mode 100644 index 0000000..647f94d --- /dev/null +++ b/share/extensions/tests/test_pdflatex.py @@ -0,0 +1,56 @@ +# coding=utf-8 +""" +Test calling pdflatex to convert formule to svg. + +This test uses cached output from the `pdflatex` command because this +test is not a test of pdflatex, but of the extension only. The mocked +output also allows testing in the CI builder without dependancies. + +To re-generate the cached files, run the pytest command: + +NO_MOCK_COMMANDS=1 pytest tests/test_pdflatex.py + +This will use pdflatex, but will also store the output of the call +to `tests/data/cmd/pdflatex/[key].msg.output (and also to `cmd/inkscape/...`) + +The key depends on the comparison arguments, so changing them will invalidate +the file and you must regenerate them. + +Remove the `.output` extension from the above file and commit it to the +repository only AFTER all the tests pass and you are happy with them. + +Clean up any old `.msg` files with invalid or old keys. + +(use EXPORT_COMPARE to generate the output svgs, see inkex.tester docs) +""" +from pdflatex import PdfLatex +from inkex.tester import ComparisonMixin, TestCase + + +class PdfLatexTest(ComparisonMixin, TestCase): + """Test some basic latex formulas""" + + compare_file = "svg/empty.svg" + effect_class = PdfLatex + comparisons = [ + ("--font_size=15",), # pdflatex 6cb1964 + ("--font_size=15", "--standalone=False"), # pdflatex acb7040 + ( + "--font_size=8", + r"""--formule=\(\begin{matrix} + a & b & c \\ + d & e & f \\ + g & h & i + \end{matrix}\)""", + ), # pdflatex fa0bf1f8 + ] + + +class PdfLatexTestmm(ComparisonMixin, TestCase): + compare_file = "svg/empty_mm.svg" + effect_class = PdfLatex + comparisons = [ + ("--font_size=20", r"--formule=\(\frac{1+\sqrt{5}}{2}\)"), # pdflatex 93c25fa3 + # pdflatex b78a3100 + ("--font_size=20", "--standalone=False", r"--formule=\(\frac{1+\sqrt{5}}{2}\)"), + ] -- cgit v1.2.3