diff --git a/tests/test_collection_export_lifecycle.py b/tests/test_collection_export_lifecycle.py index 4bf5dbf..8084c0c 100644 --- a/tests/test_collection_export_lifecycle.py +++ b/tests/test_collection_export_lifecycle.py @@ -33,7 +33,11 @@ def window(tmp_path, monkeypatch): try: ui = app.App() break - except app.tk.TclError: + except (app.tk.TclError, RuntimeError) as exc: + # tkinterdnd2 wraps a failed "package require tkdnd" in a plain + # RuntimeError; treat that like the transient TclError it hides. + if isinstance(exc, RuntimeError) and "tkdnd" not in str(exc): + raise partial = getattr(app.tk, "_default_root", None) if partial is not None: try: diff --git a/tests/test_ui_accessibility.py b/tests/test_ui_accessibility.py index fa7add5..1b1be8e 100644 --- a/tests/test_ui_accessibility.py +++ b/tests/test_ui_accessibility.py @@ -34,12 +34,16 @@ def setUp(self) -> None: self._second_doc = tmp_path / "Paper_Markierungen.pdf" self._second_doc.write_bytes(b"%PDF-1.4\n%%EOF\n") - last_error: tk.TclError | None = None + last_error: Exception | None = None for _attempt in range(3): try: self.app = DokuReader.App() break - except tk.TclError as exc: + except (tk.TclError, RuntimeError) as exc: + # tkinterdnd2 wraps a failed "package require tkdnd" in a + # plain RuntimeError; treat it like the TclError it hides. + if isinstance(exc, RuntimeError) and "tkdnd" not in str(exc): + raise last_error = exc partial_root = getattr(tk, "_default_root", None) if partial_root is not None: