Skip to content

Commit

Permalink
fix: support pytest 8 (#855)
Browse files Browse the repository at this point in the history
* chore: update devcontainer python to 3.12

* chore: update poetry to 1.7.1

* fix: support pytest 8
  • Loading branch information
noahnu committed Feb 7, 2024
1 parent 950997e commit 3175615
Show file tree
Hide file tree
Showing 10 changed files with 340 additions and 335 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
@@ -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
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
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
@@ -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
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
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
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
@@ -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
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

0 comments on commit 3175615

Please sign in to comment.