Opened 6 years ago

Closed 6 years ago

#14677 closed (wontfix)

tests.py cannot be split to package always

Reported by: Jari Pennanen Owned by: nobody
Component: Testing framework Version: master
Severity: Keywords:
Cc: mmcnickle Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

My tests.py grew too big, and followed advice to split it to package tests, but not all features are supported that way, which is a shame, there really should be support.

Especially the models defined in tests.py cannot be moved to individual tests/sometest.py, even though one imports all from sometest.py in tests/__init__.py it keeps throwing error that the model is not created to database.

See also my django-users discussion, for more thorough example.

Change History (4)

comment:1 Changed 6 years ago by Russell Keith-Magee

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 6 years ago by mmcnickle

Cc: mmcnickle added

comment:3 Changed 6 years ago by Carl Meyer

This is parallel to #4470, which should be fixed by merging the GSOC branch to fix #3591. In the meantime the same workaround (explicit Meta.app_label on the models) works just as well.

It's also possible (I haven't tested) that the #3591 GSOC branch might break the technique of putting models in tests.py entirely; as far as I know that technique has never been documented or officially supported. Though perhaps it should be; seems like a relatively clean solution for #7835.

comment:4 Changed 6 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

@carljm makes a fair point. Django's test suite puts models in tests.py, but that isn't a documented capability, and it has some fairly nasty side effects (not the least of which is dirtying of the content types and app cache).

I'm going to marking this closed wontfix; it's an undocumented capability, and rather than paper over the problem, we should be focussing on #7835 to provide the "real" solution.

Note: See TracTickets for help on using tickets.
Back to Top