From bdfaa08f37ac33f546aad11b96615ba6301a0f17 Mon Sep 17 00:00:00 2001 From: Nicolas Kruse Date: Mon, 19 May 2025 11:16:08 +0200 Subject: [PATCH] tests updated --- tests/__init__.py | 0 tests/test_latex_embedding.py | 8 +- tests/test_rendering_example1_doc.py | 4 +- tests/test_rendering_example2_doc.py | 2 +- tests/test_rendering_markdown.py | 2 +- tests/test_svg.py | 151 +++++++++++++++++++++++++++ 6 files changed, 157 insertions(+), 10 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/test_svg.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_latex_embedding.py b/tests/test_latex_embedding.py index 80af3c0..6fd415c 100644 --- a/tests/test_latex_embedding.py +++ b/tests/test_latex_embedding.py @@ -22,9 +22,7 @@ def test_latex_embedding2(): contains the interaction parameter \Phi_{ij}, which describes the influence of component j on the transport properties of component i. - The interaction parameter \Phi_{ij} is given by the relation shown in @eq:ExampleFormula2. - \Phi_{ij} = \frac{1}{\sqrt{8}} \left(1 + \frac{M_i}{M_j} \right)^{-1/2} \left[ 1 + \left( \frac{\lambda_i}{\lambda_j} \right)^{1/2} \left( \frac{M_j}{M_i} \right)^{1/4} \right]^2 - """) + The interaction parameter \Phi_{ij} is given by the relation shown in @eq:ExampleFormula2.\Phi_{ij} = \frac{1}{\sqrt{8}} \left(1 + \frac{M_i}{M_j} \right)^{-1/2} \left[ 1 + \left( \frac{\lambda_i}{\lambda_j} \right)^{1/2} \left( \frac{M_j}{M_i} \right)^{1/4} \right]^2""") dummy = pyladoc.DocumentWriter() result_string = dummy._equation_embedding_reescaping(test_input) @@ -44,9 +42,7 @@ def test_latex_embedding(): """) expected_output = pyladoc._normalize_text_indent(r""" - # Test - \Phi_{ij} = \frac{1}{\sqrt{8}} - This i is inline LaTeX. + # Test\Phi_{ij} = \frac{1}{\sqrt{8}}This i is inline LaTeX. """) dummy = pyladoc.DocumentWriter() diff --git a/tests/test_rendering_example1_doc.py b/tests/test_rendering_example1_doc.py index fb47de4..2dd5cee 100644 --- a/tests/test_rendering_example1_doc.py +++ b/tests/test_rendering_example1_doc.py @@ -1,10 +1,10 @@ import pyladoc import matplotlib.pyplot as plt import pandas as pd -import document_validation +from . import document_validation import numpy as np -VALIDATE_HTML_CODE_ONLINE = False +VALIDATE_HTML_CODE_ONLINE = True WRITE_RESULT_FILES = True diff --git a/tests/test_rendering_example2_doc.py b/tests/test_rendering_example2_doc.py index e9f913e..00357e1 100644 --- a/tests/test_rendering_example2_doc.py +++ b/tests/test_rendering_example2_doc.py @@ -1,7 +1,7 @@ import pyladoc import matplotlib.pyplot as plt import pandas as pd -import document_validation +from . import document_validation VALIDATE_HTML_CODE_ONLINE = False WRITE_RESULT_FILES = True diff --git a/tests/test_rendering_markdown.py b/tests/test_rendering_markdown.py index a602582..81cdb74 100644 --- a/tests/test_rendering_markdown.py +++ b/tests/test_rendering_markdown.py @@ -1,5 +1,5 @@ import pyladoc -import document_validation +from . import document_validation VALIDATE_HTML_CODE_ONLINE = False WRITE_RESULT_FILES = True diff --git a/tests/test_svg.py b/tests/test_svg.py new file mode 100644 index 0000000..faa4c84 --- /dev/null +++ b/tests/test_svg.py @@ -0,0 +1,151 @@ +import pyladoc + +def test_update_svg_ids(): + test_str = r""" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + """ + + unique_id = 'xx-rgerergre-yy-trhsrthrst--xx' + + result = pyladoc.svg_tools.update_svg_ids(test_str, unique_id) + + print(result) + + assert result.replace(f"svg-{unique_id}-", '') == test_str \ No newline at end of file