diff --git a/.gitignore b/.gitignore index fd09476..4a85b00 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ __pycache__ build dist src/pytask_parallel/_version.py +tests/test_jupyter/file.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5857bd5..347348a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -65,7 +65,7 @@ repos: attrs, cloudpickle, loky, - pytask>=0.4.0, + pytask>=0.4.5, rich, types-click, types-setuptools, diff --git a/CHANGES.md b/CHANGES.md index 1210989..4a64b3e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask-parallel) and - {pull}`72` moves the project to `pyproject.toml`. - {pull}`75` updates the release strategy. - {pull}`79` add tests for Jupyter and fix parallelization with `PythonNode`s. +- {pull}`82` fixes testing with pytask v0.4.5. ## 0.4.0 - 2023-10-07 diff --git a/environment.yml b/environment.yml index 7b2ab71..27498f2 100644 --- a/environment.yml +++ b/environment.yml @@ -12,7 +12,7 @@ dependencies: - toml # Package dependencies - - pytask>=0.4.0 + - pytask>=0.4.5 - cloudpickle - loky - optree diff --git a/pyproject.toml b/pyproject.toml index d9a0995..df23f52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ dependencies = [ "cloudpickle", "loky", "pluggy>=1.0.0", - "pytask>=0.4.0", + "pytask>=0.4.5", "rich" ] dynamic = ["version"] @@ -52,8 +52,8 @@ Tracker = "https://github.com/pytask-dev/pytask-parallel/issues" [tool.setuptools] include-package-data = true zip-safe = false -platforms = [ "any",] -license-files = [ "LICENSE",] +platforms = ["any"] +license-files = ["LICENSE"] [tool.check-manifest] ignore = ["src/pytask_parallel/_version.py"] diff --git a/tests/conftest.py b/tests/conftest.py index 8cba383..ef47c25 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,11 +1,14 @@ from __future__ import annotations +import os import sys from contextlib import contextmanager from typing import Callable import pytest from click.testing import CliRunner +from nbmake.pytest_items import NotebookItem +from pytask import storage class SysPathsSnapshot: @@ -62,6 +65,7 @@ def _restore_sys_path_and_module_after_test_execution(): class CustomCliRunner(CliRunner): def invoke(self, *args, **kwargs): """Restore sys.path and sys.modules after an invocation.""" + storage.create() with restore_sys_path_and_module_after_test_execution(): return super().invoke(*args, **kwargs) @@ -69,3 +73,11 @@ def invoke(self, *args, **kwargs): @pytest.fixture() def runner(): return CustomCliRunner() + + +def pytest_collection_modifyitems(session, config, items) -> None: # noqa: ARG001 + """Add markers to Jupyter notebook tests.""" + if sys.platform == "darwin" and "CI" in os.environ: # pragma: no cover + for item in items: + if isinstance(item, NotebookItem): + item.add_marker(pytest.mark.xfail(reason="Fails regularly on MacOS"))