Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/test_traitlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2829,6 +2829,25 @@ class SuperHasTraits(HasTraits):
assert not hasattr(obj, "b")


def test_configurable_unrecognized_args_user_warning():
"""Configurable should surface unknown kwargs as UserWarning (#926)."""
import warnings

from traitlets.config.configurable import Configurable

with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
Configurable(not_a_trait=1)
user = [w for w in caught if issubclass(w.category, UserWarning)]
assert user
assert "Passing unrecognized arguments" in str(user[0].message)
assert not any(
issubclass(w.category, DeprecationWarning)
and "Passing unrecognized arguments" in str(w.message)
for w in caught
)


def test_default_mro():
"""Verify that default values follow mro"""

Expand Down
2 changes: 1 addition & 1 deletion traitlets/traitlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ def ignore(change: Bunch) -> None:
f"{e}\n"
"This is deprecated in traitlets 4.2."
"This error will be raised in a future release of traitlets.",
DeprecationWarning,
UserWarning,
stacklevel=2,
)

Expand Down
Loading