Skip to content

Commit

Permalink
fixup! Emit warning for broken object
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Jun 9, 2019
1 parent 012551e commit cc5f8ce
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions testing/test_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,15 +1234,17 @@ def __getattr__(self, _):
raise KeyError("This should be an AttributeError")


@pytest.mark.parametrize(
@pytest.mark.parametrize( # pragma: no branch (lambdas are not called)
"stop", [None, _is_mocked, lambda f: None, lambda f: False, lambda f: True]
)
def test_warning_on_unwrap_of_broken_object(stop):
bad_instance = Broken()
assert inspect.unwrap.__module__ == "inspect"
with _patch_unwrap_mock_aware():
assert inspect.unwrap.__module__ != "inspect"
with pytest.raises(KeyError):
with pytest.warns(pytest.PytestWarning):
with pytest.warns(
pytest.PytestWarning, match="^Got KeyError.* when unwrapping"
):
with pytest.raises(KeyError):
inspect.unwrap(bad_instance, stop=stop)
assert inspect.unwrap.__module__ == "inspect"

0 comments on commit cc5f8ce

Please sign in to comment.