Skip to content

Commit

Permalink
fix: fixture definition incompatibility with 8.x.x series pytest.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCardin committed Mar 4, 2024
1 parent 98696c6 commit b68dd2e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@ 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"

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
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 b68dd2e

Please sign in to comment.