Opened 8 years ago

Closed 8 years ago

#18199 closed New feature (wontfix)

A way to have Django apps specific test runners

Reported by: Miguel Araujo Owned by: nobody
Component: Testing framework Version: 1.4
Severity: Normal Keywords: tests, testrunner, testing
Cc: miguel.araujo.perez@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no



I maintain an application named <a href="">django-rules</a> that for testing has a an app specific test runner, named

I got <a href="">this ticket openned</a>. When testing django-rules through the common approach python test django_rules it breaks. This is because running tests this way, Django autodetects my TestCases but doesn't use the runner itself, which has some test preparation (custom settings, real models only for testing).

Apparently there is no way to tell Django to use my runner for running tests, and Django doesn't automatically use the runner either. I could probably adapt my test suite to use new @override_setting decorator and mock objects. But the behavior I'm testing is very specific and attached to models itself.

What do you think? seems a reasonable use case?


Change History (2)

comment:1 Changed 8 years ago by Anssi Kääriäinen

For the settings part there is already @override_setting.

I discussed with maraujop about this issue in IRC. The problem is that a reusable app needs models for testing. Having them in will create them also into production databases. I tried to find a clean way to have the models only available for testing, but could not find one.

I don't think having an app-specific test runner is the right way forward. The test runner is one level above the apps. I do think the use case is valid, as it would be nice to have models for testing without polluting the production database.

If there is already some way to achieve this then it should be documented. If this is already documented, then sorry for the noise. (I tried to look through the docs). Googling gave me this:, but this does not work for the reusable-app case.

comment:2 Changed 8 years ago by Carl Meyer

Resolution: wontfix
Status: newclosed

Test-only models are already tracked by ticket #7835. This could be closed as duplicate of that, but since it specifically requested per-app test runners, which is something that isn't really feasible, I'm going to close wontfix.

I think the best practical solution here for reusable apps today is to put the tests in a different module (not appname.tests; perhaps appname.tests.tests) so that they aren't run at all by end-user projects, because there's very little value in that.

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