Skip to content

Commit

Permalink
added pytest marker 'needs_dependencies' to fix test_tutorials(), als…
Browse files Browse the repository at this point in the history
…o made version_switcher use built-in Github Actions's triggers instead of a workaround
  • Loading branch information
ZergLev committed Nov 18, 2024
1 parent 64c5c7e commit 5c75e99
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/generate_version_switcher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
workflows: ["build_and_publish_docs"]
types:
- completed
tags:
- v[0-9]+.[0-9]+.[0-9]+
workflow_dispatch:

concurrency:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ markers = [
"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",
"needs_dependencies: marks tests as requiring poetry.lock dependencies to run"
]
asyncio_mode = "auto"

Expand Down
2 changes: 2 additions & 0 deletions scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def _test(coverage: bool = False, dependencies: bool = False, quick: bool = Fals
]
else:
args = [
"-m",
"not needs_dependencies",
"--allow-skip=all",
*args,
]
Expand Down
3 changes: 2 additions & 1 deletion tests/tutorials/test_tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
CHATSKY_TUTORIAL_PY_FILES = map(str, (PROJECT_ROOT_DIR / "tutorials").glob("./**/*.py"))


@pytest.mark.needs_dependencies
def check_tutorial_dependencies(venv: "VirtualEnv", tutorial_source_code: str):
"""
Install dependencies required by a tutorial in `venv` and run the tutorial.
Expand All @@ -35,7 +36,7 @@ def check_tutorial_dependencies(venv: "VirtualEnv", tutorial_source_code: str):
versions_dict = InstallationCell.versions()
for deps in re.findall(InstallationCell.pattern, tutorial_source_code):
venv.run(
f"python -m pip install {deps}".replace("chatsky=={chatsky}", ".").format(**versions_dict),
f"python -m pip install {deps}".replace("chatsky", ".").format(**versions_dict),
check_rc=True,
cd=os.getcwd(),
)
Expand Down

0 comments on commit 5c75e99

Please sign in to comment.