diff --git a/hypothesis-python/RELEASE.rst b/hypothesis-python/RELEASE.rst new file mode 100644 index 0000000000..c2fccceec7 --- /dev/null +++ b/hypothesis-python/RELEASE.rst @@ -0,0 +1,4 @@ +RELEASE_TYPE: minor + +:py:mod:`hypothesis.errors` will now raise :py:exc:`AttributeError` when attempting +to access an undefined attribute, rather than returning :py:obj:`None`. diff --git a/hypothesis-python/src/hypothesis/errors.py b/hypothesis-python/src/hypothesis/errors.py index 06b77de29d..651e7a45fe 100644 --- a/hypothesis-python/src/hypothesis/errors.py +++ b/hypothesis-python/src/hypothesis/errors.py @@ -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.""" diff --git a/hypothesis-python/tests/cover/test_escalation.py b/hypothesis-python/tests/cover/test_escalation.py index e8ad8623fe..212f462c51 100644 --- a/hypothesis-python/tests/cover/test_escalation.py +++ b/hypothesis-python/tests/cover/test_escalation.py @@ -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())