django_coverage_plugin: Missing DJANGO_SETTINGS_MODULE

With empty .coveragerc:

$ coverage run foo/manage.py test bar
[...works...]

With django-coverage-plugin in .coveragerc:

[run]
plugins =
  django_coverage_plugin
$ coverage run foo/manage.py test bar
[...]
django.core.exceptions.ImproperlyConfigured: Requested setting TEMPLATES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

manage.py is unmodified (generated by Django).

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I was getting the following error:

django_coverage_plugin.plugin.DjangoTemplatePluginException: Template debugging must be enabled in settings.

I thought I had the setting enabled, but here’s the thing:

The TEMPLATE_DEBUG setting is deprecated in Django 1.8. The new way to do it is described here: https://stackoverflow.com/a/32446043/2319697

DEBUG = True

TEMPLATES = [
    {
        ...
        'OPTIONS': {
            'debug': DEBUG,
        },
    },
]

Error is gone 🎉