Skip to content
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

fix: support pytest 8 #855

Merged
merged 5 commits into from
Feb 7, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.224.3/containers/python-3/.devcontainer/base.Dockerfile

# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
ARG VARIANT="3.11-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
ARG VARIANT="3.12-bookworm"
FROM mcr.microsoft.com/devcontainers/python:${VARIANT}

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local on arm64/Apple Silicon.
"VARIANT": "3.11-bullseye",
"VARIANT": "3.12-bookworm",
// Options
"NODE_VERSION": "none"
}
Expand Down
2 changes: 1 addition & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"stabilityDays": 7,
"labels": ["dependencies"],
"constraints": {
"poetry": "1.6.1"
"poetry": "1.7.1"
},
}
2 changes: 1 addition & 1 deletion .poetry-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.1
1.7.1
643 changes: 321 additions & 322 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ syrupy = 'syrupy'

[tool.poetry.dependencies]
python = '>=3.8.1,<4'
pytest = '>=7.0.0,<8.0.0'
pytest = '>=7.0.0,<9.0.0'

[tool.poetry.group.test.dependencies]
invoke = '^2.0.0'
Expand All @@ -39,7 +39,7 @@ pytest-xdist = '^3.1.0'

[tool.poetry.group.dev.dependencies]
isort = '^5.12.0'
black = '^23.1.0'
black = '^24.1.0'
mypy = '^1.0.1'
py-githooks = '^1.1.1'
flake8 = '^7.0.0'
Expand Down
2 changes: 1 addition & 1 deletion src/syrupy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def pytest_runtest_logfinish(nodeid: str) -> None:
_syrupy.ran_item(nodeid)


@pytest.hookimpl(tryfirst=True) # type: ignore[misc]
@pytest.hookimpl(tryfirst=True)
def pytest_sessionfinish(session: "pytest.Session", exitstatus: int) -> None:
"""
Finish session run and set exit status.
Expand Down
1 change: 1 addition & 0 deletions tests/examples/test_custom_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
and then simply re-use them, without having to pass those defaults to every assert.
Especially useful if there's a lot of tests that need to modify the default behaviour.
"""

import pytest

from syrupy.extensions.json import JSONSnapshotExtension
Expand Down
1 change: 1 addition & 0 deletions tests/examples/test_custom_snapshot_name.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Example: Custom Snapshot Name
"""

import pytest

from syrupy.extensions.amber import AmberSnapshotExtension
Expand Down
14 changes: 9 additions & 5 deletions tests/integration/test_pytest_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ def test_ignores_non_function_nodes(testdir):
conftest = """
import pytest

class CustomItem(pytest.Item, pytest.File):
def __init__(self, *args, fspath, parent, **kwargs):
super().__init__(fspath, parent=parent)
class CustomItem(pytest.Item):
def __init__(self, name, **kwargs):
super().__init__(name, **kwargs)
self._nodeid += "::CUSTOM"

def runtest(self):
pass

def pytest_collect_file(path, parent):
return CustomItem.from_parent(fspath=path, parent=parent)
def pytest_collect_file(file_path, parent):
return CustomItem.from_parent(
name=file_path.name,
path=file_path,
parent=parent
)
"""
testcase = """
def test_example(snapshot):
Expand Down