Skip to content

Commit

Permalink
Install local dff in tutorial tests (#202)
Browse files Browse the repository at this point in the history
* install dff locally

* remove tutorial tests from coverage runs
  • Loading branch information
RLKRo authored Aug 21, 2023
1 parent f2c208e commit 9c61fa6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion tests/tutorials/test_tutorials.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import TYPE_CHECKING
import re
from pathlib import Path
import os

import pytest

Expand Down Expand Up @@ -31,14 +32,15 @@ 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)


@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()
Expand Down

0 comments on commit 9c61fa6

Please sign in to comment.