Is it possible to have a set of models just for testing purposes? The idea is that I’ve written an app that contains some helper abstract model HelperBase. Now I’d like to provide some models that would inherit from it in order to test it, say DerivedTest1, DerivedTest2. However I wouldn’t really like those test models to appear in the production database in the end. I just want their tables to be constructed in the test database. Is it possible and if so – how to do it? I’ve already tried creating models in the tests.py file but this doesn’t seem to work.
Is it possible to have a set of models just for testing purposes? The
Share
You could try creating a whole new app that you only use on your development server.
E.g., if your app is called
myappyou would call your testing appmyapp_test.Then in
myapp_test‘smodels.pyyou wouldfrom myapp import modelsand then subclass your models in there.Then in your
settings.pyyou either just try and remember to comment out themyapp_testapplication fromINSTALLED_APPSwhen deploying to your production server. Or you can use thelocal_settings.pymethodology to only have themyapp_testincluded inINSTALLED_APPSon your test machine.