diff --git a/makefile b/makefile index 713b08836..29c18e687 100644 --- a/makefile +++ b/makefile @@ -56,7 +56,7 @@ wait_db: docker_up .PHONY: wait_db test: venv - source <(cat .env_file | sed 's/=/=/' | sed 's/^/export /') && pytest --cov-fail-under=$(TEST_COVERAGE_THRESHOLD) --cov-report html --cov-report term --cov=dff --allow-skip=$(TEST_ALLOW_SKIP) tests/ + source <(cat .env_file | sed 's/=/=/' | sed 's/^/export /') && pytest -m "not no_coverage" --cov-fail-under=$(TEST_COVERAGE_THRESHOLD) --cov-report html --cov-report term --cov=dff --allow-skip=$(TEST_ALLOW_SKIP) tests/ .PHONY: test test_all: venv wait_db test lint diff --git a/pytest.ini b/pytest.ini index fdb92a986..639c6c663 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,5 +3,6 @@ markers = docker: marks tests as requiring docker containers to work telegram: marks tests as requiring telegram client API token to work slow: marks tests as slow (taking more than a minute to complete) + no_coverage: tests that either cannot run inside the `coverage` workflow or do not affect coverage stats all: reserved by allow-skip none: reserved by allow-skip diff --git a/tests/tutorials/test_tutorials.py b/tests/tutorials/test_tutorials.py index d21ad1b6f..bdd8a1e8c 100644 --- a/tests/tutorials/test_tutorials.py +++ b/tests/tutorials/test_tutorials.py @@ -1,6 +1,7 @@ from typing import TYPE_CHECKING import re from pathlib import Path +import os import pytest @@ -31,7 +32,7 @@ def check_tutorial_dependencies(venv: "VirtualEnv", tutorial_source_code: str): fd.write(tutorial_source_code) for deps in re.findall(InstallationCell.pattern, tutorial_source_code): - venv.run(f"python -m pip install {deps}", check_rc=True) + venv.run(f"python -m pip install {deps}".replace("dff", "."), check_rc=True, cd=os.getcwd()) venv.run(f"python {tutorial_path}", check_rc=True) @@ -39,6 +40,7 @@ def check_tutorial_dependencies(venv: "VirtualEnv", tutorial_source_code: str): @pytest.mark.parametrize("dff_tutorial_py_file", DFF_TUTORIAL_PY_FILES) @pytest.mark.slow @pytest.mark.docker +@pytest.mark.no_coverage def test_tutorials(dff_tutorial_py_file, virtualenv): with open(dff_tutorial_py_file, "r", encoding="utf-8") as fd: source_code = fd.read()