Skip to content

Fix testing for pytask v0.4.5. #82

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

Merged
merged 5 commits into from
Jan 12, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ __pycache__
build
dist
src/pytask_parallel/_version.py
tests/test_jupyter/file.txt
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ repos:
attrs,
cloudpickle,
loky,
pytask>=0.4.0,
pytask>=0.4.5,
rich,
types-click,
types-setuptools,
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- toml

# Package dependencies
- pytask>=0.4.0
- pytask>=0.4.5
- cloudpickle
- loky
- optree
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies = [
"cloudpickle",
"loky",
"pluggy>=1.0.0",
"pytask>=0.4.0",
"pytask>=0.4.5",
"rich"
]
dynamic = ["version"]
Expand Down Expand Up @@ -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"]
Expand Down
12 changes: 12 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -62,10 +65,19 @@ 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)


@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"))