Repository navigation
Support async tests decorated with override_config - #676
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Cancellation during setup can skip cleanup while the worker still applies overrides, leaking configuration into subsequent tests.
1 open issue
What changed in this PR
Adds async support to override_config, addressing #522 by preserving coroutine detection and keeping overrides active until the awaited test finishes.
Changes:
- Adds an async wrapper with thread-sensitive setup and cleanup, while preserving synchronous and class decoration.
- Adds regressions for coroutine detection, override lifetime, return values, exception restoration, and database-backed usage.
- Documents async test support.
| File | Description |
|---|---|
tests/test_test_overrides.py |
Adds async decorator regressions, including database backend coverage. |
docs/testing.rst |
Documents override lifetime for async tests. |
constance/test/unittest.py |
Adds coroutine-aware wrapping with worker-thread setup and cleanup. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

Keep
override_config-decorated coroutine functions recognizable as async tests and retain overrides until the awaited function finishes. Run synchronous override setup/cleanup in a thread-sensitive worker so the database backend remains usable; always restore values when the test raises. Synchronous functions and class decoration keep the existing path.Closes #522.
Validation on CPython 3.13.12 / Django 5.2.18: new regressions fail on the original wrapper, then cover coroutine identity, values across suspension, return values, exception restoration, direct async test methods and a real SQLite backend. Full unittest run passes (169 tests, 1 intentional skip); full pytest passes (176 passed, 1 skipped, 6 existing sync-access warnings). CI-pinned Ruff 0.5.0 lint/format checks pass on both changed Python files; migration check reports no changes. The full unittest suite also passes on CPython 3.11.16 / Django 4.2.30 (169 tests, 1 intentional skip). Other matrix combinations and hosted CI were not verified. Redis tests use the repository mock; no real Redis server was used. Documentation text was checked but not built locally.