Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install local dff in tutorial tests #202

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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