INTERNALERROR when generating html report using pytest-cov 7.1.0 with jinja
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 58/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- python
- Ambito
- testing-qa
Direzione di ricerca
Start with the minimal reproducer at https://github.com/cdleonard/check-pytest-cov-jinja and run uv run pytest --cov --cov-report=html. Compare that result with pytest-cov 7.0.0 using the provided command, then trace the HTML-report path shown in the traceback. Done means the Jinja template is handled without an INTERNALERROR and the HTML report is generated.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
It seems that latest version of pytest-cov will attempt to parse jinja2 files as python sources and fail. Error looks like this:
============================= test session starts ==============================
platform linux -- Python 3.12.3, pytest-9.1.1, pluggy-1.6.0
rootdir: /home/leonard/Projects/check-pytest-cov-jinja
configfile: pyproject.toml
plugins: cov-7.1.0
collected 1 item
test_jinja.py .
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/_pytest/main.py", line 330, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/_pytest/main.py", line 384, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR> raise exception
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR> teardown.throw(exception)
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/_pytest/logging.py", line 816, in pytest_runtestloop
INTERNALERROR> return (yield) # Run all the tests.
INTERNALERROR> ^^^^^
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR> teardown.throw(exception)
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/_pytest/terminal.py", line 708, in pytest_runtestloop
INTERNALERROR> result = yield
INTERNALERROR> ^^^^^
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 152, in _multicall
INTERNALERROR> teardown.send(result)
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/pytest_cov/plugin.py", line 362, in pytest_runtestloop
INTERNALERROR> self.cov_total = self.cov_controller.summary(self.cov_report)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/pytest_cov/engine.py", line 44, in ensure_topdir_wrapper
INTERNALERROR> return meth(self, *args, **kwargs)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/pytest_cov/engine.py", line 189, in summary
INTERNALERROR> self.cov.html_report(ignore_errors=True, directory=output)
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/coverage/control.py", line 1275, in html_report
INTERNALERROR> return reporter.report(morfs)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/coverage/html.py", line 392, in report
INTERNALERROR> self.write_html_page(ftr)
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/coverage/html.py", line 481, in write_html_page
INTERNALERROR> file_data = self.datagen.data_for_file(ftr.fr, ftr.analysis)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/coverage/html.py", line 152, in data_for_file
INTERNALERROR> for lineno, tokens in enumerate(fr.source_token_lines(), start=1):
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/coverage/phystokens.py", line 136, in source_token_lines
INTERNALERROR> soft_key_lines = find_soft_key_lines(source)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/home/leonard/Projects/check-pytest-cov-jinja/.venv/lib/python3.12/site-packages/coverage/phystokens.py", line 97, in find_soft_key_lines
INTERNALERROR> for node in ast.walk(ast.parse(source)):
INTERNALERROR> ^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/usr/lib/python3.12/ast.py", line 52, in parse
INTERNALERROR> return compile(source, filename, mode, flags,
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "<unknown>", line 2
INTERNALERROR> {% for key in arg %}
INTERNALERROR> ^
INTERNALERROR> SyntaxError: invalid syntax
============================== 1 passed in 0.06s ===============================
This does not happen with pytest-cov 7.0.0
Minimal project reproducing just this issue: https://github.com/cdleonard/check-pytest-cov-jinja
To reproduce the failure: uv run pytest --cov --cov-report=html
To check it works using 7.0.0: uv run --with pytest-cov==7.0.0 pytest --cov --cov-report=html
- Lingua principale
- Python
- Stelle
- 2.1k
- Fork
- 253
- Merge medio
- 12g 4h
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pytest-dev/pytest-cov
-
Celery tests require package; test blows up if Celery not installed instead of skipping the tests gracefullyForse già presa @dchaudhari7177 l’ha presa 96 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pytest-dev/pytest-cov#750 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pytest-dev/pytest-cov#617 · 1 commento ·
-
Only set dynamic context on coveragepy cores supporting it, perhaps?Forse già presa @terminalchai l’ha presa 10 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
pytest-dev/pytest-cov#755 · 3 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
pytest-dev/pytest-cov#747 · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
pytest-dev/pytest-cov#746 · 2 commenti ·
Tutte le issue di pytest-dev/pytest-cov
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
aws-samples/sample-per-model-bedrock#639 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
awslabs/visual-asset-management-system#937 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
project-codeflare/codeflare-sdk#1195 ·
I maintainer di solito rispondono entro 1 giorno
-
Bump numpy dependencyAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
pandas-dev/pandas-stubs#2051 ·
I maintainer di solito rispondono entro 1 giorno