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 pytest_collect_file to take into account pytest fspath deprecation in Node constructors #26

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/pytest_cython/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import pytest
import py.path
from pathlib import Path

import _pytest
from _pytest.doctest import get_optionflags
Expand Down Expand Up @@ -54,7 +55,12 @@ def pytest_collect_file(path, parent):
# only run test if matching .so and .pyx files exist
# create addoption for this ??
if hasattr(DoctestModule, 'from_parent'):
return DoctestModule.from_parent(parent, fspath=path)
try:
# fspath for Node constructors deprecated since
# pytest version 7.0., replaced with pathlib.Path
return DoctestModule.from_parent(parent, path=Path(str(path)))
except TypeError:
return DoctestModule.from_parent(parent, fspath=path)
else:
# Backwards-compat for older pytest
return DoctestModule(path, parent)
Expand Down