Skip to content

Commit ece6156

Browse files
committed
fix tests
1 parent 5370058 commit ece6156

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/py/reactpy/reactpy/_option.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,14 @@ def __init__(self, *args: Any, message: str, **kwargs: Any) -> None:
141141

142142
@Option.current.getter # type: ignore
143143
def current(self) -> _O:
144-
warn(self._deprecation_message, DeprecationWarning)
144+
try:
145+
# we access the current value during init to debug log it
146+
# no need to warn unless it's actually used. since this attr
147+
# is only set after super().__init__ is called, we can check
148+
# for it to determine if it's being accessed by a user.
149+
msg = self._deprecation_message
150+
except AttributeError:
151+
pass
152+
else:
153+
warn(msg, DeprecationWarning)
145154
return super().current

src/py/reactpy/tests/test__option.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,6 @@ def test_option_parent_child_must_be_mutable():
132132

133133
def test_no_default_or_parent():
134134
with pytest.raises(
135-
TypeError, match="must specify either a default value or a parent"
135+
TypeError, match="Must specify either a default or a parent option"
136136
):
137137
Option("A_FAKE_OPTION")

0 commit comments

Comments
 (0)