Skip to content

Commit

Permalink
feat: update to pytest 8
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Feb 19, 2024
1 parent 978a53f commit 9b1ab52
Show file tree
Hide file tree
Showing 11 changed files with 667 additions and 604 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
pull_request:
branches: [main]

env:
PYTHON_VERSION: "3.10"
POETRY_VERSION: "1.7.1"

jobs:
main:
name: Test and release
Expand All @@ -16,29 +20,30 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.10
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache poetry
id: cache-poetry
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-${{ runner.os }}
key: poetry-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ env.POETRY_VERSION }}
- name: Install poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-in-project: true
- name: Cache venv
id: cache-venv
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }}
key: venv-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ env.POETRY_VERSION }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-
venv-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ env.POETRY_VERSION }}-
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: poetry install
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"bungcip.better-toml"
"ms-python.black-formatter",
"tamasfe.even-better-toml"
]
}
16 changes: 3 additions & 13 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
{
"python.pythonPath": "${workspaceFolder}/.venv",
"python.formatting.provider": "black",
"python.languageServer": "Pylance",
"python.linting.enabled": false,
"python.linting.pylintEnabled": false,
"python.linting.banditEnabled": false,
"python.linting.flake8Enabled": false,
"python.linting.mypyEnabled": false,
"python.linting.prospectorEnabled": false,
"python.linting.pycodestyleEnabled": false,
"python.linting.pydocstyleEnabled": false,
"python.linting.pylamaEnabled": false,
"[python]": {
"editor.tabSize": 4,
"editor.formatOnSave": true,
"editor.formatOnType": false,
"editor.formatOnPaste": false,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "ms-python.black-formatter"
}
}
35 changes: 22 additions & 13 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"check": "poetry run pyright"
},
"devDependencies": {
"pyright": "^1.1.278"
"pyright": "^1.1.350"
}
}
1,169 changes: 610 additions & 559 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions poetry.toml

This file was deleted.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ classifiers = ["Framework :: Pytest"]
include = ["pytest_insta/py.typed"]

[tool.poetry.dependencies]
python = "^3.8"
pytest = "^7.2.0"
python = "^3.10"
pytest = ">=7.2.0,<9.0.0"
wrapt = "^1.14.1"

[tool.poetry.group.dev.dependencies]
black = "^22.10.0"
isort = "^5.10.1"
black = "^24.2.0"
isort = "^5.13.2"
python-semantic-release = "^7.32.1"

[tool.poetry.plugins.pytest11]
Expand All @@ -43,7 +43,7 @@ addopts = "tests --import-mode=importlib"
typeCheckingMode = "strict"

[tool.black]
target-version = ["py38"]
target-version = ["py310"]

[tool.isort]
profile = "black"
Expand Down
2 changes: 1 addition & 1 deletion pytest_insta/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SnapshotFixture:

@classmethod
def from_request(cls, request: fixtures.FixtureRequest) -> "SnapshotFixture":
path, name = node_path_name(request.node)
path, name = node_path_name(request.node) # type: ignore
path = path.with_name("snapshots") / name
session: SnapshotSession = getattr(request.config, "_snapshot_session")
return cls(session[path], session)
Expand Down
15 changes: 12 additions & 3 deletions pytest_insta/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,21 @@ class SnapshotSession(Dict[Path, SnapshotContext]):

def __post_init__(self):
self.config = self.session.config
record_dir = self.config.cache.makedir("insta")

self.tr = self.config.pluginmanager.getplugin("terminalreporter")
cache = self.config.cache
if not cache:
raise TypeError("No cache")

record_dir = cache.mkdir("insta")
self.record_dir = Path(os.path.relpath(Path(record_dir), Path(".").resolve()))
self.strategy = self.config.option.insta

tr = self.config.pluginmanager.getplugin("terminalreporter")
if not isinstance(tr, TerminalReporter):
raise TypeError("No TerminalReporter")

self.tr = tr

self.strategy = self.config.option.insta
if self.strategy == "auto":
self.strategy = "update-none" if is_ci() else "update-new"

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# This is a shim to allow Github to detect the package, build is done with poetry
# This is a shim to allow GitHub to detect the package. The build is done with poetry.

import setuptools

Expand Down

0 comments on commit 9b1ab52

Please sign in to comment.