Skip to content

Commit cc5f8ce

Browse files
committed
fixup! Emit warning for broken object
1 parent 012551e commit cc5f8ce

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

testing/test_doctest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,15 +1234,17 @@ def __getattr__(self, _):
12341234
raise KeyError("This should be an AttributeError")
12351235

12361236

1237-
@pytest.mark.parametrize(
1237+
@pytest.mark.parametrize( # pragma: no branch (lambdas are not called)
12381238
"stop", [None, _is_mocked, lambda f: None, lambda f: False, lambda f: True]
12391239
)
12401240
def test_warning_on_unwrap_of_broken_object(stop):
12411241
bad_instance = Broken()
12421242
assert inspect.unwrap.__module__ == "inspect"
12431243
with _patch_unwrap_mock_aware():
12441244
assert inspect.unwrap.__module__ != "inspect"
1245-
with pytest.raises(KeyError):
1246-
with pytest.warns(pytest.PytestWarning):
1245+
with pytest.warns(
1246+
pytest.PytestWarning, match="^Got KeyError.* when unwrapping"
1247+
):
1248+
with pytest.raises(KeyError):
12471249
inspect.unwrap(bad_instance, stop=stop)
12481250
assert inspect.unwrap.__module__ == "inspect"

0 commit comments

Comments
 (0)