From f0ef1bcce444c2db8e392cce0e0af1e55d32a457 Mon Sep 17 00:00:00 2001 From: Jan Suhr Date: Mon, 28 Jul 2025 11:17:51 +0200 Subject: [PATCH] fix unit tests --- document_page_reference/models/document_page.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/document_page_reference/models/document_page.py b/document_page_reference/models/document_page.py index 1e3d86e7..92a4812d 100644 --- a/document_page_reference/models/document_page.py +++ b/document_page_reference/models/document_page.py @@ -23,12 +23,10 @@ try: class Context(SandboxedEnvironment.context_class): def resolve_or_missing(self, key): res = super().resolve_or_missing(key) - if res is not Undefined: + if not isinstance(res, Undefined): return res - try: - return self.parent["ref"](key) - except KeyError: - return Undefined() + # If the key is not found in the normal context, try to resolve it as a reference + return self.parent["ref"](key) class Environment(SandboxedEnvironment): context_class = Context