Skip to content

Commit

Permalink
Merge pull request #101 from schireson/dc/pytest-81
Browse files Browse the repository at this point in the history
fix: fixture definition incompatibility with 8.x.x series pytest.
  • Loading branch information
DanCardin authored Mar 4, 2024
2 parents 98696c6 + 637f28c commit 270a81b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,23 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
pytest-version: ["6.2.0", "7.0.0"]
pytest-asyncio-version: ["0.16.0", "0.19.0"]
pytest-version: ["6.2.0", "7.0.0", "8.1.0"]
pytest-asyncio-version: ["0.16.0", "0.23.0"]
sqlalchemy-version: ["1.3.0", "1.4.0", "2.0.0"]

exclude:
# old versions of pytest-asyncio use old pytest hook syntax
- pytest-version: "8.1.0"
pytest-asyncio-version: "0.16.0"

# new pytest versions are only 3.8 compatible
- pytest-version: "8.1.0"
python-version: "3.7"

# new pytest-asyncio versions are only 3.8 compatible
- pytest-asyncio-version: "0.23.0"
python-version: "3.7"

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pytest-alembic"
version = "0.10.7"
version = "0.11.0"
description = "A pytest plugin for verifying alembic migrations."
authors = [
"Dan Cardin <[email protected]>",
Expand Down
11 changes: 9 additions & 2 deletions src/pytest_alembic/plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ class PytestAlembicPlugin:

# Some weird decisions were made by pytest it seems like. There is not an obvious
# way to support both <7 and >=7 without weird nonsense like this.
if pytest_version_tuple and pytest_version_tuple[0] >= 7:
if pytest_version_tuple and pytest_version_tuple >= (8, 1, 0):

def pytest_collect_file(self, file_path, path, parent): # noqa: ARG002
def pytest_collect_file(self, file_path, parent):
if self.should_register(file_path):
return TestCollector.from_parent(parent, path=file_path)
return None

elif pytest_version_tuple and pytest_version_tuple[0] >= 7:

def pytest_collect_file(self, file_path, path, parent): # type: ignore[misc] # noqa: ARG002
if self.should_register(file_path):
return TestCollector.from_parent(parent, path=file_path)
return None
Expand Down

0 comments on commit 270a81b

Please sign in to comment.