Skip to content

Commit

Permalink
Fix cache clearing of "attr" attribute on test monkey-patches
Browse files Browse the repository at this point in the history
  • Loading branch information
vdboor committed Jul 11, 2024
1 parent 2a59c64 commit c2858f1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/schematools/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,15 @@ def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.data!r})"

def __setitem__(self, key, value):
if key in self.data and key in self.__dict__:
"""Check for changes to the dictionary data. Note this is also called on __init__()."""
if key == "auth" and key in self.data:
logger.warning("auth field is patched by tests")

if (
key in self.__dict__
and (prop := getattr(self.__class__, key, None)) is not None
and isinstance(prop, cached_property)
):
# Clear the @cached_property cache value
del self.__dict__[key]
super().__setitem__(key, value)
Expand Down

0 comments on commit c2858f1

Please sign in to comment.