{"action":"created","issue":{"url":"https://api.github.com/repos/nedbat/django_coverage_plugin/issues/18","repository_url":"https://api.github.com/repos/nedbat/django_coverage_plugin","labels_url":"https://api.github.com/repos/nedbat/django_coverage_plugin/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/nedbat/django_coverage_plugin/issues/18/comments","events_url":"https://api.github.com/repos/nedbat/django_coverage_plugin/issues/18/events","html_url":"https://github.com/nedbat/django_coverage_plugin/issues/18","id":130530474,"number":18,"title":"Missing DJANGO_SETTINGS_MODULE","user":{"login":"jonashaag","id":175722,"avatar_url":"https://avatars.githubusercontent.com/u/175722?v=3","gravatar_id":"","url":"https://api.github.com/users/jonashaag","html_url":"https://github.com/jonashaag","followers_url":"https://api.github.com/users/jonashaag/followers","following_url":"https://api.github.com/users/jonashaag/following{/other_user}","gists_url":"https://api.github.com/users/jonashaag/gists{/gist_id}","starred_url":"https://api.github.com/users/jonashaag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonashaag/subscriptions","organizations_url":"https://api.github.com/users/jonashaag/orgs","repos_url":"https://api.github.com/users/jonashaag/repos","events_url":"https://api.github.com/users/jonashaag/events{/privacy}","received_events_url":"https://api.github.com/users/jonashaag/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":19,"created_at":"2016-02-02T00:42:36Z","updated_at":"2016-06-03T22:17:43Z","closed_at":"2016-06-02T16:07:38Z","body":"With empty `.coveragerc`:\r\n\r\n```\r\n$ coverage run foo/manage.py test bar\r\n[...works...]\r\n```\r\n\r\nWith django-coverage-plugin in `.coveragerc`:\r\n\r\n```\r\n[run]\r\nplugins =\r\n  django_coverage_plugin\r\n```\r\n\r\n```\r\n$ coverage run foo/manage.py test bar\r\n[...]\r\ndjango.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.\r\n```\r\n\r\n`manage.py` is unmodified (generated by Django)."},"comment":{"url":"https://api.github.com/repos/nedbat/django_coverage_plugin/issues/comments/223708069","html_url":"https://github.com/nedbat/django_coverage_plugin/issues/18#issuecomment-223708069","issue_url":"https://api.github.com/repos/nedbat/django_coverage_plugin/issues/18","id":223708069,"user":{"login":"emmalemma","id":341080,"avatar_url":"https://avatars.githubusercontent.com/u/341080?v=3","gravatar_id":"","url":"https://api.github.com/users/emmalemma","html_url":"https://github.com/emmalemma","followers_url":"https://api.github.com/users/emmalemma/followers","following_url":"https://api.github.com/users/emmalemma/following{/other_user}","gists_url":"https://api.github.com/users/emmalemma/gists{/gist_id}","starred_url":"https://api.github.com/users/emmalemma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emmalemma/subscriptions","organizations_url":"https://api.github.com/users/emmalemma/orgs","repos_url":"https://api.github.com/users/emmalemma/repos","events_url":"https://api.github.com/users/emmalemma/events{/privacy}","received_events_url":"https://api.github.com/users/emmalemma/received_events","type":"User","site_admin":false},"created_at":"2016-06-03T22:17:43Z","updated_at":"2016-06-03T22:17:43Z","body":"Sure. I can reproduce this with a minimal pytest setup:\r\n\r\n```\r\nvirtualenv -p python3 venv\r\nsource venv/bin/activate\r\npip install django pytest pytest-django pytest-cov\r\npip install -e \"git+https://github.com/nedbat/django_coverage_plugin@fdb0892966362e2ded39e4124d095a999a28543e#egg=django_coverage_plugin\"\r\n\r\ndjango-admin startproject coverage_test\r\ncd coverage_test\r\necho \"[run]\\nplugins=django_coverage_plugin\" > .coveragerc\r\n\r\nmkdir coverage_test/templates\r\necho \"test\" > coverage_test/templates/test.html\r\n```\r\n\r\ncreate `tests.py`:\r\n```\r\nfrom django.template.loader import render_to_string\r\n\r\ndef test():\r\n\trender_to_string('test.html')\r\n```\r\n\r\nedit settings.py:\r\n```\r\nINSTALLED_APPS.append('coverage_test')\r\nTEMPLATES[0]['OPTIONS']['debug'] = True\r\n```\r\n\r\nDemonstrate it works:\r\n\r\n```\r\n> export DJANGO_SETTINGS_MODULE=coverage_test.settings\r\n> py.test tests.py --cov coverage_test\r\n\r\n====================================== test session starts =======================================\r\nplatform darwin -- Python 3.5.1, pytest-2.9.2, py-1.4.31, pluggy-0.3.1\r\ndjango settings: coverage_test.settings (from environment variable)\r\nrootdir: /Users/emma/Dropbox/Projects/coverage_test/coverage_test, inifile: \r\nplugins: cov-2.2.1, django-2.9.1\r\ncollected 1 items \r\n\r\ntests.py .\r\n------------------------ coverage: platform darwin, python 3.5.1-final-0 -------------------------\r\nName                                Stmts   Miss  Cover\r\n-------------------------------------------------------\r\ncoverage_test/__init__.py               0      0   100%\r\ncoverage_test/settings.py              20      0   100%\r\ncoverage_test/templates/test.html       1      0   100%\r\ncoverage_test/urls.py                   3      3     0%\r\ncoverage_test/wsgi.py                   4      4     0%\r\n-------------------------------------------------------\r\nTOTAL                                  28      7    75%\r\n\r\n==================================== 1 passed in 0.32 seconds ====================================\r\n```\r\n\r\nThen set `TEMPLATES[0]['OPTIONS']['debug'] = False`, and demonstrate it fails silently:\r\n\r\n```\r\n> py.test tests.py --cov coverage_test\r\n\r\n====================================== test session starts =======================================\r\nplatform darwin -- Python 3.5.1, pytest-2.9.2, py-1.4.31, pluggy-0.3.1\r\ndjango settings: coverage_test.settings (from environment variable)\r\nrootdir: /Users/emma/Dropbox/Projects/coverage_test/coverage_test, inifile: \r\nplugins: cov-2.2.1, django-2.9.1\r\ncollected 1 items \r\n\r\ntests.py .\r\n------------------------ coverage: platform darwin, python 3.5.1-final-0 -------------------------\r\nName                        Stmts   Miss  Cover\r\n-----------------------------------------------\r\ncoverage_test/__init__.py       0      0   100%\r\ncoverage_test/settings.py      20      0   100%\r\ncoverage_test/urls.py           3      3     0%\r\ncoverage_test/wsgi.py           4      4     0%\r\n-----------------------------------------------\r\nTOTAL                          27      7    74%\r\n\r\n==================================== 1 passed in 0.27 seconds ====================================\r\n```\r\n\r\nIf I run the same thing on emmalemma@e083da1, with `check_debug` disabled, it shows 0% coverage:\r\n\r\n```\r\n> py.test tests.py --cov coverage_test\r\n\r\n====================================== test session starts =======================================\r\nplatform darwin -- Python 3.5.1, pytest-2.9.2, py-1.4.31, pluggy-0.3.1\r\ndjango settings: coverage_test.settings (from environment variable)\r\nrootdir: /Users/emma/Dropbox/Projects/coverage_test/coverage_test, inifile: \r\nplugins: cov-2.2.1, django-2.9.1\r\ncollected 1 items \r\n\r\ntests.py .\r\n------------------------ coverage: platform darwin, python 3.5.1-final-0 -------------------------\r\nName                                Stmts   Miss  Cover\r\n-------------------------------------------------------\r\ncoverage_test/__init__.py               0      0   100%\r\ncoverage_test/settings.py              20      0   100%\r\ncoverage_test/templates/test.html       1      0   100%\r\ncoverage_test/urls.py                   3      3     0%\r\ncoverage_test/wsgi.py                   4      4     0%\r\n-------------------------------------------------------\r\nTOTAL                                  28      7    75%\r\n\r\n==================================== 1 passed in 0.23 seconds ====================================\r\n```\r\n\r\nPresumably, the check in fdb0892 is working properly, and killing the plugin; it's just not getting to stderr or stopping pytest.\r\n\r\nThe original issue is probably fixed by this patch. There might not be anything for the plugin to do about my problem, since it's probably something in pytest or pytest-cov. Or there might a configuration somewhere. I haven't spent much time hunting since the actual plugin is working just fine for me."}}
{"actor":{"display_login":"emmalemma"}}