Molly Davey
Molly Davey

Reputation: 183

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. Example of one of my apps.py files:

from django.apps import AppConfig

class ReportsConfig(AppConfig):
    name = 'reports'

Upvotes: 18

Views: 3040

Answers (1)

udo
udo

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

Related Questions