Provide the ability for model definitions that are only availably during testing
|Reported by:||russellm||Owned by:||kkubasik|
|Severity:||Normal||Keywords:||feature test models|
|Cc:||martin@…, oliver@…, t.django@…, steingrd@…, kmike84@…, adrianlopezcalvo@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
A current limitation of the unit test framework is that there is no capacity to define 'test models' - that is, models that are only required for the purposes of testing. A regular installation would not know anything about these models - only a test database would have access to them.
There are several existing applications that have a need for this capability: For example:
- contrib.admin: you can't test the way admin handles models without some models to handle.
- contrib.databrowse: you can't test the way the browser works without having models to browse
- Django Evolution: you can't evolve models without having some models to evolve.
The easiest way to work around this at present is to have a standalone test project which exercises the required functionality. However, these tests aren't integrated into the automated test suite, so they.
Another option is to do some app_cache munging during the test - this works, but is very messy.
Django should provide a way for model definitions to be defined as part of the test definition, synchronized as part of the test setup, populated and manipulated during test execution, and destroyed along with the test database.
Change History (41)
comment:1 Changed 7 years ago by jamesturk
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Design decision needed
comment:2 Changed 7 years ago by russellm
- Triage Stage changed from Design decision needed to Accepted