Reputation: 183
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. Example of one of my apps.py files:
from django.apps import AppConfig
class ReportsConfig(AppConfig):
name = 'reports'
Upvotes: 18
Views: 3040
Reputation: 5180
you could 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')
Upvotes: 20