{"action":"created","issue":{"url":"https://api.github.com/repos/nedbat/django_coverage_plugin/issues/29","repository_url":"https://api.github.com/repos/nedbat/django_coverage_plugin","labels_url":"https://api.github.com/repos/nedbat/django_coverage_plugin/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/nedbat/django_coverage_plugin/issues/29/comments","events_url":"https://api.github.com/repos/nedbat/django_coverage_plugin/issues/29/events","html_url":"https://github.com/nedbat/django_coverage_plugin/issues/29","id":198017283,"number":29,"title":"Breaking running of coverage when enabled","user":{"login":"clokep","id":517124,"avatar_url":"https://avatars.githubusercontent.com/u/517124?v=3","gravatar_id":"","url":"https://api.github.com/users/clokep","html_url":"https://github.com/clokep","followers_url":"https://api.github.com/users/clokep/followers","following_url":"https://api.github.com/users/clokep/following{/other_user}","gists_url":"https://api.github.com/users/clokep/gists{/gist_id}","starred_url":"https://api.github.com/users/clokep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clokep/subscriptions","organizations_url":"https://api.github.com/users/clokep/orgs","repos_url":"https://api.github.com/users/clokep/repos","events_url":"https://api.github.com/users/clokep/events{/privacy}","received_events_url":"https://api.github.com/users/clokep/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-29T14:40:38Z","updated_at":"2017-01-02T21:32:24Z","closed_at":null,"body":"First, thanks for this great plug-in! I've found it quite useful for testing some of the logic in my templates. 👍 \r\n\r\nI know this used to work in my project, but I'm not sure when it broke. (I don't think this has updated in a while, it could have been a Django update that broke this?)\r\n\r\nMy project is using Django 1.10.4, coverage 4.3.1, django-coverage-plugin 1.3.1. (I also tried with coverage 4.2, that exhibited the same behavior.)\r\n\r\nWhile running with this I'm getting a stack trace:\r\n```bash\r\n/vagrant$ coverage run manage.py test\r\nCoverage.py warning: Disabling plugin 'django_coverage_plugin.DjangoTemplatePlugin' due to an exception:\r\nTraceback (most recent call last):\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/coverage/control.py\", line 497, in _should_trace_internal\r\n    file_tracer = plugin.file_tracer(canonical)\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django_coverage_plugin/plugin.py\", line 154, in file_tracer\r\n    check_debug()\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django_coverage_plugin/plugin.py\", line 55, in check_debug\r\n    templates = getattr(settings, 'TEMPLATES', [])\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/conf/__init__.py\", line 53, in __getattr__\r\n    self._setup(name)\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/conf/__init__.py\", line 41, in _setup\r\n    self._wrapped = Settings(settings_module)\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/conf/__init__.py\", line 97, in __init__\r\n    mod = importlib.import_module(self.SETTINGS_MODULE)\r\n  File \"/usr/lib/python2.7/importlib/__init__.py\", line 37, in import_module\r\n    __import__(name)\r\n  File \"/vagrant/my_project/settings.py\", line 8, in <module>\r\n    from django.contrib.messages import constants as message_constants\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/contrib/messages/__init__.py\", line 1, in <module>\r\n    from django.contrib.messages.api import *  # NOQA\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/contrib/messages/api.py\", line 3, in <module>\r\n    from django.http import HttpRequest\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/http/__init__.py\", line 5, in <module>\r\n    from django.http.response import (\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/http/response.py\", line 13, in <module>\r\n    from django.core.serializers.json import DjangoJSONEncoder\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/core/serializers/__init__.py\", line 23, in <module>\r\n    from django.core.serializers.base import SerializerDoesNotExist\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/core/serializers/base.py\", line 4, in <module>\r\n    from django.db import models\r\nImportError: cannot import name models\r\nTraceback (most recent call last):\r\n  File \"manage.py\", line 45, in <module>\r\n    execute_from_command_line(sys.argv)\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py\", line 367, in execute_from_command_line\r\n    utility.execute()\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py\", line 316, in execute\r\n    settings.INSTALLED_APPS\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/conf/__init__.py\", line 53, in __getattr__\r\n    self._setup(name)\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/conf/__init__.py\", line 41, in _setup\r\n    self._wrapped = Settings(settings_module)\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/conf/__init__.py\", line 97, in __init__\r\n    mod = importlib.import_module(self.SETTINGS_MODULE)\r\n  File \"/usr/lib/python2.7/importlib/__init__.py\", line 37, in import_module\r\n    __import__(name)\r\n  File \"/vagrant/my_project/settings.py\", line 8, in <module>\r\n    from django.contrib.messages import constants as message_constants\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/contrib/messages/__init__.py\", line 1, in <module>\r\n    from django.contrib.messages.api import *  # NOQA\r\n  File \"/usr/local/venv/local/lib/python2.7/site-packages/django/contrib/messages/api.py\", line 1, in <module>\r\n    from django.contrib.messages import constants\r\nImportError: cannot import name constants\r\n```\r\n\r\nThis seems to be because I'm importing `django.contrib.messages.constants` in my settings file, note that if I remove this line I get other errors about importing. This seems related to loading of Django settings before Django is configured (see https://github.com/nedbat/django_coverage_plugin/issues/28#issuecomment-243723099), but with much worse consequences.\r\n\r\nLet me know if there is anything I can do to help confirm my suspicion or narrow this down! Thanks."},"comment":{"url":"https://api.github.com/repos/nedbat/django_coverage_plugin/issues/comments/270022500","html_url":"https://github.com/nedbat/django_coverage_plugin/issues/29#issuecomment-270022500","issue_url":"https://api.github.com/repos/nedbat/django_coverage_plugin/issues/29","id":270022500,"user":{"login":"nedbat","id":23789,"avatar_url":"https://avatars.githubusercontent.com/u/23789?v=3","gravatar_id":"","url":"https://api.github.com/users/nedbat","html_url":"https://github.com/nedbat","followers_url":"https://api.github.com/users/nedbat/followers","following_url":"https://api.github.com/users/nedbat/following{/other_user}","gists_url":"https://api.github.com/users/nedbat/gists{/gist_id}","starred_url":"https://api.github.com/users/nedbat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nedbat/subscriptions","organizations_url":"https://api.github.com/users/nedbat/orgs","repos_url":"https://api.github.com/users/nedbat/repos","events_url":"https://api.github.com/users/nedbat/events{/privacy}","received_events_url":"https://api.github.com/users/nedbat/received_events","type":"User","site_admin":false},"created_at":"2017-01-02T21:32:24Z","updated_at":"2017-01-02T21:32:24Z","body":"@clokep: Sorry things are going badly. I haven't had time to work on the Django template plugin in quite a while, and it might be a while before I do.  What I'd really like is to find someone else to take it over... :("}}
{"actor":{"display_login":"nedbat"}}