Skip to content

Commit

Permalink
Merge pull request #1731 from braingram/pytest_8p1
Browse files Browse the repository at this point in the history
require pytest 7+ update for pytest 8.1.dev
  • Loading branch information
braingram authored Jan 23, 2024
2 parents 198b9ed + 5c7f56c commit 7ae2d7e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ The ASDF Standard is at v1.6.0
of an ASDF file (with the option ``tagged`` to load the contents
as a tree of ``asdf.tagged.Tagged`` instances to preserve tags) [#1700]

- Require pytest 7+ and update asdf pytest plugin to be compatible
with the current development version of pytest (8.1) [#1731]

3.0.1 (2023-10-30)
------------------

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ tests = [
"fsspec[http]>=2022.8.2",
"lz4>=0.10",
"psutil",
"pytest>=6",
"pytest>=7",
"pytest-doctestplus",
"pytest-remotedata",
]
Expand Down
21 changes: 8 additions & 13 deletions pytest_asdf/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,8 @@ def from_parent(
xfail_tests=None,
**kwargs,
):
# Fix for depreciation of fspath in pytest 7+
if pytest.__version__ >= "7.0.0":
path = pathlib.Path(fspath)
kwargs["path"] = path
else:
path = fspath
kwargs["fspath"] = path
path = pathlib.Path(fspath)
kwargs["path"] = path

if hasattr(super(), "from_parent"):
result = super().from_parent(parent, **kwargs)
Expand Down Expand Up @@ -287,7 +282,7 @@ def _parse_test_list(content):
return result


def pytest_collect_file(path, parent):
def pytest_collect_file(file_path, parent):
if not (parent.config.getini("asdf_schema_tests_enabled") or parent.config.getoption("asdf_tests")):
return None

Expand All @@ -306,12 +301,12 @@ def pytest_collect_file(path, parent):

schema_roots = [os.path.join(str(parent.config.rootdir), os.path.normpath(root)) for root in schema_roots]

if path.ext != ".yaml":
if file_path.suffix != ".yaml":
return None

for root in schema_roots:
if str(path).startswith(root) and path.purebasename not in skip_names:
posix_path = pathlib.Path(path).as_posix()
if str(file_path).startswith(root) and file_path.stem not in skip_names:
posix_path = pathlib.Path(file_path).as_posix()
schema_skip_tests = []
for suffix, names in skip_tests.items():
if posix_path.endswith(suffix):
Expand All @@ -323,8 +318,8 @@ def pytest_collect_file(path, parent):

return AsdfSchemaFile.from_parent(
parent,
fspath=path,
skip_examples=(path.purebasename in skip_examples),
fspath=file_path,
skip_examples=(file_path.stem in skip_examples),
validate_default=validate_default,
ignore_unrecognized_tag=ignore_unrecognized_tag,
ignore_version_mismatch=ignore_version_mismatch,
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ deps =
numpydev: cython
oldestdeps: minimum_dependencies
parallel: pytest-xdist
pytestdev: pytest>=0.0.dev0
pytestdev: git+https://github.com/pytest-dev/pytest
# released versions of doctestplus aren't compatible with pytest-dev
pytestdev: git+https://github.com/scientific-python/pytest-doctestplus
extras = all,tests
# astropy will complain if the home directory is missing
pass_env = HOME
Expand Down

0 comments on commit 7ae2d7e

Please sign in to comment.