Skip to content

Commit

Permalink
Merge pull request #3633 from pganssle/errors-getattr
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Apr 30, 2023
2 parents b926247 + 47bd5f9 commit bc4395e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hypothesis-python/RELEASE.rst
@@ -0,0 +1,4 @@
RELEASE_TYPE: patch

``hypothesis.errors`` will now raise :py:exc:`AttributeError` when attempting
to access an undefined attribute, rather than returning :py:obj:`None`.
2 changes: 2 additions & 0 deletions hypothesis-python/src/hypothesis/errors.py
Expand Up @@ -132,6 +132,8 @@ def __getattr__(name):
)
return BaseExceptionGroup

raise AttributeError(f"Module 'hypothesis.errors' has no attribute {name}")


class DeadlineExceeded(_Trimmable):
"""Raised when an individual test body has taken too long to run."""
Expand Down
5 changes: 5 additions & 0 deletions hypothesis-python/tests/cover/test_escalation.py
Expand Up @@ -72,5 +72,10 @@ def test_multiplefailures_deprecation():
assert exc is BaseExceptionGroup


def test_errors_attribute_error():
with pytest.raises(AttributeError):
errors.ThisIsNotARealAttributeDontCreateSomethingWithThisName


def test_handles_null_traceback():
esc.get_interesting_origin(Exception())

0 comments on commit bc4395e

Please sign in to comment.