diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7ca6008c..089b44f8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,7 @@ jobs: allow-prereleases: true - run: pip install tox - - if: matrix.os == 'ubunut-latest' + - if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install graphviz graphviz-dev diff --git a/docs/source/changes.md b/docs/source/changes.md index bcb601ab..51e38be2 100644 --- a/docs/source/changes.md +++ b/docs/source/changes.md @@ -5,6 +5,10 @@ chronological order. Releases follow [semantic versioning](https://semver.org/) releases are available on [PyPI](https://pypi.org/project/pytask) and [Anaconda.org](https://anaconda.org/conda-forge/pytask). +## 0.4.5 - 2023-12-xx + +- {pull}`515` enables tests with graphviz in CI. Thanks to {user}`NickCrews`. + ## 0.4.4 - 2023-12-04 - {pull}`509` improves the documentation. diff --git a/pyproject.toml b/pyproject.toml index 90c3c605..4d5e3cac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,14 @@ docs = [ "sphinx-toolbox", "sphinxext-opengraph", ] -test = ["pytest", "pytest-cov", "pytest-xdist", "syrupy", "deepdiff", "pexpect"] +test = [ + "deepdiff", + "pexpect", + "pytest", + "pytest-cov", + "pytest-xdist", + "syrupy", +] [project.urls] Changelog = "https://pytask-dev.readthedocs.io/en/stable/changes.html" diff --git a/tests/test_dag_command.py b/tests/test_dag_command.py index 9ec0c819..30ae7561 100644 --- a/tests/test_dag_command.py +++ b/tests/test_dag_command.py @@ -1,6 +1,6 @@ from __future__ import annotations -import shutil +import os import sys import textwrap @@ -16,26 +16,18 @@ else: _IS_PYGRAPHVIZ_INSTALLED = True +# Test should run always on remote except on Windows and locally only with the package +# installed. +_TEST_SHOULD_RUN = _IS_PYGRAPHVIZ_INSTALLED or ( + os.environ.get("CI") and sys.platform != "win32" +) _GRAPH_LAYOUTS = ["neato", "dot", "fdp", "sfdp", "twopi", "circo"] - - -_PARAMETRIZED_LAYOUTS = [ - pytest.param( - layout, - marks=pytest.mark.skip(reason=f"{layout} not available") - if shutil.which(layout) is None - else [], - ) - for layout in _GRAPH_LAYOUTS -] - - _TEST_FORMATS = ["dot", "pdf", "png", "jpeg", "svg"] @pytest.mark.end_to_end() -@pytest.mark.skipif(not _IS_PYGRAPHVIZ_INSTALLED, reason="pygraphviz is required") -@pytest.mark.parametrize("layout", _PARAMETRIZED_LAYOUTS) +@pytest.mark.skipif(not _TEST_SHOULD_RUN, reason="pygraphviz is required") +@pytest.mark.parametrize("layout", _GRAPH_LAYOUTS) @pytest.mark.parametrize("format_", _TEST_FORMATS) @pytest.mark.parametrize("rankdir", ["LR"]) def test_create_graph_via_cli(tmp_path, runner, format_, layout, rankdir): @@ -70,8 +62,8 @@ def task_example(): pass @pytest.mark.end_to_end() -@pytest.mark.skipif(not _IS_PYGRAPHVIZ_INSTALLED, reason="pygraphviz is required") -@pytest.mark.parametrize("layout", _PARAMETRIZED_LAYOUTS) +@pytest.mark.skipif(not _TEST_SHOULD_RUN, reason="pygraphviz is required") +@pytest.mark.parametrize("layout", _GRAPH_LAYOUTS) @pytest.mark.parametrize("format_", _TEST_FORMATS) @pytest.mark.parametrize("rankdir", [_RankDirection.LR.value, _RankDirection.TB]) def test_create_graph_via_task(tmp_path, runner, format_, layout, rankdir): diff --git a/tox.ini b/tox.ini index 201e7a3a..3a336c7b 100644 --- a/tox.ini +++ b/tox.ini @@ -2,16 +2,13 @@ envlist = pytest [testenv] +passenv = CI usedevelop = true -platform = - linux: linux - macos: darwin - windows: win32 [testenv:pytest] extras = test deps = - linux, macos: pygraphviz + pygraphviz;platform_system != "Windows" commands = pytest {posargs} -vv