Skip to content

Plugin will be disabled due to exception when extra engine is not django.template.backends.django.DjangoTemplates #101

@danilo-botelho

Description

@danilo-botelho

When multiple template engines are used, django_coverage_plugin will check them all and raise DjangoTemplatePluginException which will cause it to be disabled by coverage. Instead, it should work for the DjangoTemplates engine and ignore the others.

SETTINGS.PY

TEMPLATES = [
    {
        # https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        # https://docs.djangoproject.com/en/dev/ref/settings/#dirs
        "DIRS": [str(APPS_DIR / "templates")],
        # https://docs.djangoproject.com/en/dev/ref/settings/#app-dirs
        "APP_DIRS": True,
        "OPTIONS": {
            # https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
            "context_processors": [
                "django.template.context_processors.debug",
                "django.template.context_processors.request",
                "django.contrib.auth.context_processors.auth",
                "django.template.context_processors.i18n",
                "django.template.context_processors.media",
                "django.template.context_processors.static",
                "django.template.context_processors.tz",
                "django.contrib.messages.context_processors.messages",
            ],
            "builtins": ["template_partials.templatetags.partials"],
        },
    },
    {
        "BACKEND": "post_office.template.backends.post_office.PostOfficeTemplates",
        "APP_DIRS": True,
        "DIRS": [],
        "OPTIONS": {
            "context_processors": [
                "django.contrib.auth.context_processors.auth",
                "django.template.context_processors.debug",
                "django.template.context_processors.i18n",
                "django.template.context_processors.media",
                "django.template.context_processors.static",
                "django.template.context_processors.tz",
                "django.template.context_processors.request",
            ],
        },
    },
]

TRACEBACK

/tmp/poetry_cache/virtualenvs/.venv/lib/python3.12/site-packages/coverage/inorout.py:378: CoverageWarning: Disabling plug-in 'django_coverage_plugin.DjangoTemplatePlugin' due to an exception:
Traceback (most recent call last):
File "/tmp/poetry_cache/virtualenvs/.venv/lib/python3.12/site-packages/coverage/inorout.py", line 363, in should_trace
file_tracer = plugin.file_tracer(canonical)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/poetry_cache/virtualenvs/.venv/lib/python3.12/site-packages/django_coverage_plugin/plugin.py", line 181, in file_tracer
self.debug_checked = check_debug()
^^^^^^^^^^^^^
File "/tmp/poetry_cache/virtualenvs/.venv/lib/python3.12/site-packages/django_coverage_plugin/plugin.py", line 88, in check_debug
raise DjangoTemplatePluginException(
django_coverage_plugin.plugin.DjangoTemplatePluginException: Can't use non-Django templates.

self.warn(f"Disabling plug-in {plugin_name!r} due to an exception:\n{tb}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions