Testing apps.py in django

How can I write a test to cover my apps.py files for each model in a django application? I need 100% code coverage and cannot figure out how to test these files. An example of one of my apps.py files:

from django.apps import AppConfig class ReportsConfig(AppConfig): name = 'reports' 
+7
django unit-testing code-coverage
source share
1 answer

you can do it like this:

 from django.apps import apps from django.test import TestCase from reports.apps import ReportsConfig class ReportsConfigTest(TestCase): def test_apps(self): self.assertEqual(ReportsConfig.name, 'reports') self.assertEqual(apps.get_app_config('reports').name, 'reports') 
+3
source share

All Articles