From e9747066f1ac293dffcb49fcb07bb7c9288b1fac Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Mon, 19 Oct 2026 19:10:46 +1100 Subject: [PATCH] BE: down notifications offset issue #1851 --- .../test_notification_down_clear_timezone.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/backend/test_notification_down_clear_timezone.py b/test/backend/test_notification_down_clear_timezone.py index ae2d657a4..167bc90f9 100644 --- a/test/backend/test_notification_down_clear_timezone.py +++ b/test/backend/test_notification_down_clear_timezone.py @@ -36,11 +36,18 @@ sys.path.extend([f"{INSTALL_PATH}/server"]) import conf # noqa: E402 -# json2table isn't needed by this test (only finalize_html() uses it) and -# isn't always installed outside the container; stub it for the duration of -# the import below, then drop it so it doesn't leak into other test files. -_json2table_was_stubbed = "json2table" not in sys.modules -if _json2table_was_stubbed: +# json2table isn't needed by this test (only finalize_html() uses it), but +# notification_instance.py imports it at module level; it's a real +# requirements.txt dependency, normally installed. Only stub it, for the +# duration of the import below, when genuinely unavailable (e.g. a sandbox +# without the full requirements installed) - stubbing it unconditionally +# would shadow the real package for every other test file sharing this +# pytest session once models.notification_instance is cached in sys.modules. +try: + import json2table # noqa: F401 + _json2table_was_stubbed = False +except ImportError: + _json2table_was_stubbed = True _stub = types.ModuleType("json2table") _stub.convert = lambda *a, **k: "" sys.modules["json2table"] = _stub