Skip to content

Commit

Permalink
fix: pytest 8.1.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
hairmare committed Mar 4, 2024
1 parent 18a8551 commit 1ab1115
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
28 changes: 21 additions & 7 deletions pytest_isort/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,21 @@ def _make_path_kwargs(p):
return dict(path=Path(p)) if PYTEST_VER >= (7, 0) else dict(fspath=p)


def pytest_collect_file(path, parent):
config = parent.config
if config.option.isort and path.ext == '.py':
if not config._isort_ignore(path):
return IsortFile.from_parent(parent, **_make_path_kwargs(path))
if PYTEST_VER >= (7, 0):

def pytest_collect_file(file_path, parent):
config = parent.config
if config.option.isort and file_path.suffix == '.py':
if not config._isort_ignore(file_path):
return IsortFile.from_parent(parent, **_make_path_kwargs(file_path))

else:

def pytest_collect_file(path, parent):
config = parent.config
if config.option.isort and path.ext == '.py':
if not config._isort_ignore(path):
return IsortFile.from_parent(parent, **_make_path_kwargs(path))


def pytest_sessionfinish(session):
Expand Down Expand Up @@ -139,8 +149,12 @@ def __call__(self, path):
"""

for glob in self.ignores:
if path.fnmatch(glob):
return glob
if isinstance(path, Path):
if path.match(glob):
return glob
else:
if path.fnmatch(glob):
return glob

return False

Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
isolated_build = true
envlist =
{py37,py38,py39}-{pytest5,pytest6,pytest7}-{isort4,isort5}
py310-{pytest6,pytest7}-{isort4,isort5}
{py310,py311}-{pytest6,pytest7,pytest8}-{isort4,isort5}

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311

[testenv]
setenv = PYTHONPATH={toxinidir}
deps =
pytest5: pytest>=5,<6
pytest6: pytest>=6,<7
pytest7: pytest>=7,<8
pytest8: pytest>=8,<9
isort4: isort>=4,<5
isort5: isort>=5,<6
allowlist_externals =
Expand Down

0 comments on commit 1ab1115

Please sign in to comment.