fix: align future_safe non-specified exception test with safe/impure_safe siblings#2435
Merged
sobolevn merged 1 commit intoJun 25, 2026
Conversation
…safe siblings
The test test_future_safe_decorator_w_unexpected_error was marked xfail
because it called `await _coro_three('0')` bare — AssertionError propagated
(correct: only ZeroDivisionError is listed) and the uncaught exception
caused the test body to fail.
Both sibling decorators already test this case correctly:
- test_safe_failure_with_non_expected_error (result.safe)
- test_safe_failure_with_non_expected_error (io.impure_safe)
both use pytest.raises(AssertionError) and pass without xfail.
Bring future_safe in line: wrap the await in pytest.raises and remove the
xfail marker. No library code changed; the decorator behaviour was already
correct.
sobolevn
approved these changes
Jun 25, 2026
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2435 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 80 81 +1
Lines 2485 2565 +80
Branches 437 44 -393
==========================================
+ Hits 2485 2565 +80 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
test_future_safe_decorator_w_unexpected_erroris marked@pytest.mark.xfail(raises=AssertionError). The test body callsawait _coro_three('0')bare —_coro_threeis decorated with@future_safe((ZeroDivisionError,)), soAssertionError(from the internalassert isinstance(arg, int)) correctly propagates rather than being caught. Because there is nopytest.raisesto catch it, the test body raises and the test "fails" as xfail.The library behaviour is correct — non-specified exceptions should propagate. The test was simply written incorrectly.
Fix
Both sibling decorators already cover this case properly with
pytest.raises:test_safe_failure_with_non_expected_errorintest_result_functions/test_safe.pytest_safe_failure_with_non_expected_errorintest_ioresult_functions/test_impure_safe.pyBring
future_safein line: wrapawait _coro_three('0')inpytest.raises(AssertionError)and remove thexfailmarker. No library code is changed.Before / After
Before: 2 xfailed (
asyncio+triobackends)After: 8 passed, 0 xfailed
This pull request was prepared with the assistance of AI, under my direction and review.