Conversation
https://docs.pytest.org/en/stable/deprecations.html#applying-a-mark-to-a-fixture-function notes that applying a mark to a fixture function never had any effect. It raises an exception during test collection with pytest 9.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #986 +/- ##
==========================================
+ Coverage 88.18% 88.28% +0.09%
==========================================
Files 32 32
Lines 1007 1007
Branches 105 105
==========================================
+ Hits 888 889 +1
+ Misses 101 100 -1
Partials 18 18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Should that decorator still work with https://pypi.org/project/pytest-django ? |
|
I'm not sure I understand the question, sorry. The rule that you can't use marks on fixtures comes from pytest itself. |
| class test_DatabaseSchedulerFromAppConf(SchedulerCase): | ||
| Scheduler = TrackingScheduler | ||
|
|
||
| @pytest.mark.django_db |
There was a problem hiding this comment.
The link I posted in the issue description explains it. This is a mark applied to a fixture function. With pytest<9 it was a no-op; with pytest>=9 it is an error. It doesn't matter what the mark is.
The mark that actually matters is the one applied to the class, which my PR doesn't touch.
There was a problem hiding this comment.
Pull request overview
Updates the test suite and test dependency constraints to remain compatible with pytest 9’s stricter collection behavior around marks applied to fixture functions.
Changes:
- Removed
@pytest.mark.django_dbdecorators from autouse fixture functions (where they are ineffective and now error under pytest 9). - Relaxed the pytest upper bound for Python 3.9+ to allow pytest 9 (
<10.0).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
t/unit/test_schedulers.py |
Removes django_db marks from fixture functions; the relevant test classes are already marked django_db. |
requirements/test.txt |
Expands pytest version range for Python 3.9+ to permit pytest 9. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cclauss
left a comment
There was a problem hiding this comment.
All three test classes have @pytest.mark.django_db decorators, so this looks good to me.
https://docs.pytest.org/en/stable/deprecations.html#applying-a-mark-to-a-fixture-function notes that applying a mark to a fixture function never had any effect. It raises an exception during test collection with pytest 9.