Update for changes in fixture loading.
Review Request #14783 — Created Jan. 15, 2026 and submitted
Django 5.2 made an un-announced change that moved fixture loading to
happen at class init time rather than per-test-method. As part of this,
the_load_fixturesmethod has been made a@classmethod. This is a
fundamentally better approach, but causes numerous problems with our own
fixture code.This change updates our
FixturesCompilerMixinto operate at class-time
rather than at test function time. This requires changing the way we
hide thefixturesclassvar from the parent class, since
__getattribute__can't work.The
@add_fixturesdecorator is now a performance hit rather than a
performance benefit. In addition, thereplaceargument is no longer
possible (but luckily, nothing actually used that). I've added a warning
about the performance implications, but for now it's hidden behind an
environment variable because we use this decorator a lot.
Ran unit tests and verified that fixtures worked appropriately.
| Summary | ID |
|---|---|
| vozroonuuumnwwkwllsykxxkovwrwzsr |
| Description | From | Last Updated |
|---|---|---|
|
redefinition of unused 'Sequence' from line 18 Column: 5 Error code: F811 |
|
|
|
Is this still true with Django 5.2, now that they've moved to class init time instead of per test? |
|
|
|
These groups are in the wrong order. |
|
|
|
The docs are missing the Returns. |
|
|
|
Can you place the trailing ) on here and the next multi-line string on the following line, a la lists/dicts, … |
|
|
|
So, I'm not sure we do want to remove this.. I believe we have a lot of tests across our … |
|
|
|
This was previously missing a , optional. |
|
|
|
For multi-line strings, can we move the ) to the following line, isolating the contents like we do multi-line lists/dicts? … |
|
- Commits:
-
Summary ID vozroonuuumnwwkwllsykxxkovwrwzsr vozroonuuumnwwkwllsykxxkovwrwzsr - Diff:
-
Revision 2 (+372 -206)
Checks run (2 succeeded)
- Change Summary:
-
Move to release-5.x. It turns out that most things being
@classmethodactually happened way back in Django 1.8 (!!!!) and we just never noticed.I'll make a separate change for
_fixture_setup()being a classmethod for Django 5.0+ for the release-6.x branch. - Commits:
-
Summary ID vozroonuuumnwwkwllsykxxkovwrwzsr vozroonuuumnwwkwllsykxxkovwrwzsr - Branch:
-
release-6.xrelease-5.x
- Diff:
-
Revision 3 (+374 -206)
Checks run (2 succeeded)
-
-
-
-
Can you place the trailing
)on here and the next multi-line string on the following line, a la lists/dicts, so the string's self-contained? -
So, I'm not sure we do want to remove this.. I believe we have a lot of tests across our codebases that really do depend on fixtures being applied to specific tests, and would fail if we move all
addfixture-specified tests down into the class. I think it'll be pretty messy.I get there's a performance hit, but I think there's still value here.
-
-
For multi-line strings, can we move the
)to the following line, isolating the contents like we do multi-line lists/dicts?Same with the
sys.stderr.writebelow.
- Commits:
-
Summary ID vozroonuuumnwwkwllsykxxkovwrwzsr vozroonuuumnwwkwllsykxxkovwrwzsr - Diff:
-
Revision 4 (+382 -206)