Skip to content

fix: align future_safe non-specified exception test with safe/impure_safe siblings#2435

Merged
sobolevn merged 1 commit into
dry-python:masterfrom
gaoflow:fix/future-safe-unexpected-exception-xfail
Jun 25, 2026
Merged

fix: align future_safe non-specified exception test with safe/impure_safe siblings#2435
sobolevn merged 1 commit into
dry-python:masterfrom
gaoflow:fix/future-safe-unexpected-exception-xfail

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Problem

test_future_safe_decorator_w_unexpected_error is marked @pytest.mark.xfail(raises=AssertionError). The test body calls await _coro_three('0') bare — _coro_three is decorated with @future_safe((ZeroDivisionError,)), so AssertionError (from the internal assert isinstance(arg, int)) correctly propagates rather than being caught. Because there is no pytest.raises to 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_error in test_result_functions/test_safe.py
  • test_safe_failure_with_non_expected_error in test_ioresult_functions/test_impure_safe.py

Bring future_safe in line: wrap await _coro_three('0') in pytest.raises(AssertionError) and remove the xfail marker. No library code is changed.

Before / After

Before: 2 xfailed (asyncio + trio backends)
After: 8 passed, 0 xfailed


This pull request was prepared with the assistance of AI, under my direction and review.

…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.
@codspeed-hq

codspeed-hq Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 22 untouched benchmarks


Comparing gaoflow:fix/future-safe-unexpected-exception-xfail (1105a91) with master (6f52034)

Open in CodSpeed

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (82ef3ef) to head (1105a91).
⚠️ Report is 536 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sobolevn sobolevn merged commit df19a26 into dry-python:master Jun 25, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants