Settings issue running coverage against a single file in a Django app · Issue #1203 · nedbat/coveragepy (original) (raw)

Describe the bug

Recently upgraded to coverage 6.0b1 from 5.5 and having some issues with running it against a single file in a Django app (Python 3.9.4 on Linux).

To Reproduce

coverage erase && coverage run --source=your.source.module manage.py test --parallel 1 --keepdb your.test.module && coverage report

This results in the following error since upgrading to the beta:
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

This suggests that manage isn't being run properly or something isn't being passed through.

Expected behaviour
Runs the tests and outputs report of coverage for the file under test.

Additional context
This works fine without the --source=your.source.module parameter so that may be where things are going wrong. This was working on v5.5.