utilities to fix LaTeX issues

This commit is contained in:
sebastien committed 2026-09-29 10:53:32 +02:00
1 parent 2a4c5f4f7c
commit a56fc6e680
7 files changed
+164 -2

No files matched your search

+23
View File
@@ -9,6 +9,7 @@ from copienator_gui.app import CopienatorApp
from copienator_gui.workflow import command_display
from copienator.commands.page_splitter import _selected_inputs
from copienator import EvaluationWorkspace
from copienator.utils import LATEX_WARNING_MARKER
@unittest.skipUnless(os.environ.get("DISPLAY"), "Tk requires a display")
@@ -99,6 +100,28 @@ class GuiConvenienceTests(unittest.TestCase):
self.assertEqual(self.app.state_store.step("statement_persp")["status"], expected)
self.assertEqual(self.app.state_store.step("statement_groups")["status"], "ready")
def test_statement_latex_warnings_are_tracked_for_both_variants(self):
for variant in ("gemini", "personal"):
with self.subTest(variant=variant):
self.app._reset_latex_warnings()
self.app.state_store.update_step("statement", last_run_variant=variant)
self.app.active_step_id = "statement"
first = self.evaluation / "Text2" / "Ex 1.pdf"
second = self.evaluation / "Sol2" / "Ex 2.pdf"
marker = LATEX_WARNING_MARKER
self.app._track_latex_warnings(f"noise\n{marker}{first}")
self.assertEqual(self.app._latex_warning_paths, [])
self.app._track_latex_warnings(f"\n{marker}{second}\n{marker}{first}\n")
self.assertEqual(self.app._latex_warning_paths, [first, second])
self.assertTrue(self.app.latex_warning_button.winfo_manager())
with patch.object(self.app, "after_idle") as after_idle:
self.app._finish_process(4, False)
self.assertTrue(
any(call.args[0] == self.app._show_current_latex_warnings
for call in after_idle.call_args_list)
)
self.assertIn("2 problème(s) LaTeX", self.app.info_var.get())
def test_evaluation_buttons_are_ordered_and_open_folder_and_statement(self):
self.assertEqual(int(self.app.evaluation_entry.cget("width")), 42)
self.assertEqual(
+12
View File
@@ -1785,6 +1785,18 @@ class StandardCliTests(unittest.TestCase):
r"valid $\begin{cases} A=0 \\ B=1 \end{cases}$",
)
self.assertEqual(module.clean_string(cleaned_text, {}), cleaned_text)
percent_text = r"Code `n % p`, prose 50%, math $n \% p$ and $50%$."
escaped_percent_text = (
r"Code `n \% p`, prose 50\%, math $n \% p$ and $50\%$."
)
self.assertEqual(
module.clean_string(percent_text, {}),
escaped_percent_text,
)
self.assertEqual(
module.clean_string(escaped_percent_text, {}),
escaped_percent_text,
)
corrupted_json_escapes = (
"Formulas $"
+ "\x0c"
+2
View File
@@ -38,6 +38,7 @@ class CompileToPdfTests(unittest.TestCase):
self.assertEqual(output.read_bytes(), b"partial")
self.assertIn("Warning: LaTeX compilation reported errors", console.getvalue())
self.assertIn(utils.LATEX_WARNING_MARKER + str(output.resolve()), console.getvalue())
self.assertIn("a PDF was generated", console.getvalue())
self.assertIn("missing \\item", console.getvalue())
@@ -69,6 +70,7 @@ class CompileToPdfTests(unittest.TestCase):
self.assertFalse(output.exists())
self.assertIn("produced no PDF", console.getvalue())
self.assertIn(utils.LATEX_WARNING_MARKER + str(output.resolve()), console.getvalue())
if __name__ == "__main__":