Code

Opened 3 years ago

Closed 3 years ago

#14677 closed (wontfix)

tests.py cannot be split to package always

Reported by: Ciantic 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.

Attachments (0)

Change History (4)

comment:1 Changed 3 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 3 years ago by mmcnickle

  • Cc mmcnickle added

comment:3 Changed 3 years ago by carljm

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 3 years ago by russellm

  • Resolution set to wontfix
  • Status changed from new to closed

@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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.