Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise AttributeError in errors module #3633

Merged
merged 1 commit into from Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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())