Skip to content

Commit

Permalink
Bump pytest from 7.4.4 to 8.0.0 (#257)
Browse files Browse the repository at this point in the history
* Bump pytest from 7.4.4 to 8.0.0

Bumps [pytest](https://github.com/pytest-dev/pytest) from 7.4.4 to 8.0.0.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](pytest-dev/pytest@7.4.4...8.0.0)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Remove use of pytest-lazy-fixture

pytest-lazy-fixture is not compatible with pytest 8.0.0, and the same
ends can be achieved using FixtureRequest.getfixturevalue from pytest
itself.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Scott Stevenson <scott@stevenson.io>
dependabot[bot] and srstevenson authored Feb 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 2a54114 commit dd030f6
Showing 5 changed files with 46 additions and 72 deletions.
26 changes: 6 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ mypy = ">=1.4"
poethepoet = ">=0.22.0"
pytest = ">=7.2.1"
pytest-cov = ">=4.1.0"
pytest-lazy-fixture = ">=0.6.3"
pytest-mock = ">=3.11.1"
ruff = ">=0.1.6"

61 changes: 27 additions & 34 deletions tests/test_check_notebook.py
Original file line number Diff line number Diff line change
@@ -12,15 +12,18 @@


@pytest.mark.parametrize(
("notebook", "is_clean"),
("notebook_name", "is_clean"),
[
(pytest.lazy_fixture("clean_notebook"), True), # type: ignore[operator]
(pytest.lazy_fixture("dirty_notebook"), False), # type: ignore[operator]
(pytest.lazy_fixture("dirty_notebook_with_version"), False), # type: ignore[operator]
("clean_notebook", True),
("dirty_notebook", False),
("dirty_notebook_with_version", False),
],
)
def test_check_notebook(notebook: nbformat.NotebookNode, *, is_clean: bool) -> None:
def test_check_notebook(
notebook_name: str, *, is_clean: bool, request: pytest.FixtureRequest
) -> None:
"""Test nb_clean.check_notebook."""
notebook = request.getfixturevalue(notebook_name)
assert nb_clean.check_notebook(notebook) is is_clean


@@ -130,54 +133,44 @@ def test_check_notebook_preserve_cell_metadata_tags_special(


@pytest.mark.parametrize(
("notebook", "preserve_cell_outputs", "is_clean"),
("notebook_name", "preserve_cell_outputs", "is_clean"),
[
(
pytest.lazy_fixture("clean_notebook_with_outputs"), # type: ignore[operator]
True,
True,
),
(
pytest.lazy_fixture("clean_notebook_with_outputs"), # type: ignore[operator]
False,
False,
),
(
pytest.lazy_fixture("clean_notebook_with_outputs_with_counts"), # type: ignore[operator]
True,
False,
),
("clean_notebook_with_outputs", True, True),
("clean_notebook_with_outputs", False, False),
("clean_notebook_with_outputs_with_counts", True, False),
],
)
def test_check_notebook_preserve_outputs(
notebook: nbformat.NotebookNode, *, preserve_cell_outputs: bool, is_clean: bool
notebook_name: str,
*,
preserve_cell_outputs: bool,
is_clean: bool,
request: pytest.FixtureRequest,
) -> None:
"""Test nb_clean.check_notebook when preserving cell outputs."""
notebook = request.getfixturevalue(notebook_name)
output = nb_clean.check_notebook(
notebook, preserve_cell_outputs=preserve_cell_outputs
)
assert output is is_clean


@pytest.mark.parametrize(
("notebook", "preserve_execution_counts", "is_clean"),
("notebook_name", "preserve_execution_counts", "is_clean"),
[
(
pytest.lazy_fixture("clean_notebook_with_counts"), # type: ignore[operator]
True,
True,
),
(
pytest.lazy_fixture("clean_notebook_with_counts"), # type: ignore[operator]
False,
False,
),
("clean_notebook_with_counts", True, True),
("clean_notebook_with_counts", False, False),
],
)
def test_check_notebook_preserve_execution_counts(
notebook: nbformat.NotebookNode, *, preserve_execution_counts: bool, is_clean: bool
notebook_name: str,
*,
preserve_execution_counts: bool,
is_clean: bool,
request: pytest.FixtureRequest,
) -> None:
"""Test nb_clean.check_notebook when preserving cell execution counts."""
notebook = request.getfixturevalue(notebook_name)
output = nb_clean.check_notebook(
notebook, preserve_execution_counts=preserve_execution_counts
)
11 changes: 5 additions & 6 deletions tests/test_clean_notebook.py
Original file line number Diff line number Diff line change
@@ -15,19 +15,18 @@ def test_clean_notebook(


@pytest.mark.parametrize(
("preserve_notebook_metadata", "expected_output"),
[
(True, pytest.lazy_fixture("clean_notebook_with_notebook_metadata")), # type: ignore[operator]
(False, pytest.lazy_fixture("clean_notebook")), # type: ignore[operator]
],
("preserve_notebook_metadata", "expected_output_name"),
[(True, "clean_notebook_with_notebook_metadata"), (False, "clean_notebook")],
)
def test_clean_notebook_with_notebook_metadata(
clean_notebook_with_notebook_metadata: nbformat.NotebookNode,
*,
preserve_notebook_metadata: bool,
expected_output: nbformat.NotebookNode,
expected_output_name: str,
request: pytest.FixtureRequest,
) -> None:
"""Test nb_clean.clean_notebook with notebook metadata."""
expected_output = request.getfixturevalue(expected_output_name)
assert (
nb_clean.clean_notebook(
clean_notebook_with_notebook_metadata,
19 changes: 8 additions & 11 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -98,11 +98,7 @@ def test_remove_filter_failure(mocker: MockerFixture) -> None:


@pytest.mark.parametrize(
("notebook", "clean"),
[
(pytest.lazy_fixture("clean_notebook"), True), # type: ignore[operator]
(pytest.lazy_fixture("dirty_notebook"), False), # type: ignore[operator]
],
("notebook", "clean"), [("clean_notebook", True), ("dirty_notebook", False)]
)
def test_check_file(
mocker: MockerFixture, notebook: nbformat.NotebookNode, *, clean: bool
@@ -140,16 +136,17 @@ def test_check_file(


@pytest.mark.parametrize(
("notebook", "clean"),
[
(pytest.lazy_fixture("clean_notebook"), True), # type: ignore[operator]
(pytest.lazy_fixture("dirty_notebook"), False), # type: ignore[operator]
],
("notebook_name", "clean"), [("clean_notebook", True), ("dirty_notebook", False)]
)
def test_check_stdin(
mocker: MockerFixture, notebook: nbformat.NotebookNode, *, clean: bool
mocker: MockerFixture,
notebook_name: str,
*,
clean: bool,
request: pytest.FixtureRequest,
) -> None:
"""Test nb_clean.cli.check when input is stdin."""
notebook = request.getfixturevalue(notebook_name)
mocker.patch(
"nb_clean.cli.sys.stdin",
return_value=io.StringIO(nbformat.writes(notebook)), # type: ignore[no-untyped-call]

0 comments on commit dd030f6

Please sign in to comment.