diff --git a/conftest.py b/conftest.py index bd9f2d32d..45d2b5159 100644 --- a/conftest.py +++ b/conftest.py @@ -1,14 +1,11 @@ +from pathlib import Path + from _pytest.doctest import DoctestModule -from py.path import local collect_ignore = ['tests/messages/data', 'setup.py'] -babel_path = local(__file__).dirpath().join('babel') +babel_path = Path(__file__).parent / 'babel' -def pytest_collect_file(path, parent): - if babel_path.common(path) == babel_path: - if path.ext == ".py": - # TODO: remove check when dropping support for old Pytest - if hasattr(DoctestModule, "from_parent"): - return DoctestModule.from_parent(parent, fspath=path) - return DoctestModule(path, parent) +def pytest_collect_file(file_path: Path, parent): + if file_path.is_relative_to(babel_path) and file_path.suffix == '.py': + return DoctestModule.from_parent(parent, path=file_path) diff --git a/tox.ini b/tox.ini index dd0ee6703..97b6bc09c 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ envlist = [testenv] deps = - pytest + pytest>=6.0 pytest-cov freezegun==0.3.12 backports.zoneinfo;python_version<"3.9"