pax_global_header00006660000000000000000000000064150506665700014524gustar00rootroot0000000000000052 comment=fc5e778d31b53301247436783b25f1dcaf0e3cdd asdf-format-pytest-asdf-plugin-249fefe/000077500000000000000000000000001505066657000201725ustar00rootroot00000000000000asdf-format-pytest-asdf-plugin-249fefe/.github/000077500000000000000000000000001505066657000215325ustar00rootroot00000000000000asdf-format-pytest-asdf-plugin-249fefe/.github/CODEOWNERS000066400000000000000000000001411505066657000231210ustar00rootroot00000000000000# Requests reviews automatically for different parts of ASDF * @asdf-format/asdf-maintainers asdf-format-pytest-asdf-plugin-249fefe/.github/codecov.yml000066400000000000000000000001061505066657000236740ustar00rootroot00000000000000coverage: status: project: default: threshold: 1% asdf-format-pytest-asdf-plugin-249fefe/.github/dependabot.yml000066400000000000000000000005401505066657000243610ustar00rootroot00000000000000version: 2 updates: # Maintain dependencies for GitHub Actions (main) - package-ecosystem: "github-actions" directory: "/" target-branch: "main" schedule: interval: "weekly" # Maintain dependencies for pip (main) - package-ecosystem: "pip" directory: "/" target-branch: "main" schedule: interval: "weekly" asdf-format-pytest-asdf-plugin-249fefe/.github/workflows/000077500000000000000000000000001505066657000235675ustar00rootroot00000000000000asdf-format-pytest-asdf-plugin-249fefe/.github/workflows/build.yml000066400000000000000000000006001505066657000254050ustar00rootroot00000000000000name: build on: pull_request: release: types: [released] workflow_dispatch: jobs: build: uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v2 with: upload_to_pypi: ${{ (github.event_name == 'release') && (github.event.action == 'released') }} secrets: pypi_token: ${{ secrets.PYPI_PASSWORD_ASDF_MAINTAINER }} asdf-format-pytest-asdf-plugin-249fefe/.github/workflows/ci.yml000066400000000000000000000044511505066657000247110ustar00rootroot00000000000000name: CI on: workflow_dispatch: schedule: - cron: '0 6 * * 1' # Every Monday at 6am UTC push: branches: - main - '*.x' tags: - '*' pull_request: # We also want this workflow triggered if the `jsonschema` label is # added or present when PR is updated types: - synchronize - labeled # Only cancel in-progress jobs or runs for the current workflow # This cancels the already triggered workflows for a specific PR without canceling # other instances of this workflow (other PRs, scheduled triggers, etc) when something # within that PR re-triggers this CI concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - uses: actions/setup-python@v5 - uses: pre-commit/action@v3.0.1 core: needs: [pre-commit] uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v2 with: submodules: false # Any env name which does not start with `pyXY` will use this Python version. default_python: '3.12' envs: | - linux: py313 - linux: py312 - linux: py312-oldasdf dev: needs: [core] uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v2 with: submodules: false # Any env name which does not start with `pyXY` will use this Python version. default_python: '3.12' envs: | - linux: py314 python-version: '3.14-dev' # separate pytest so a failure here doesn't cause the whole suite to fail - linux: py312-pytestdev downstream: if: (!contains(github.event.pull_request.labels.*.name, 'Skip Downstream')) needs: [core] uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v2 with: submodules: false # Any env name which does not start with `pyXY` will use this Python version. default_python: '3.12' envs: | - linux: downstream-standard - linux: downstream-transform - linux: downstream-wcs - linux: downstream-coordinates - linux: downstream-astropy - linux: downstream-stdatamodels - linux: downstream-sunpy - linux: downstream-dkist - linux: downstream-weldx asdf-format-pytest-asdf-plugin-249fefe/.gitignore000066400000000000000000000014531505066657000221650ustar00rootroot00000000000000# pyenv local files .python-version # Compiled files *.py[co] *.a *.o *.so __pycache__ # Ignore .c files by default to avoid including generated code. If you want to # add a non-generated .c extension, use `git add -f filename.c`. *.c # Other generated files */cython_version.py htmlcov .coverage MANIFEST coverage.xml # Tox .tox .pytest_cache # Sphinx docs/api docs/_build # Eclipse editor project files .project .pydevproject .settings # Pycharm editor project files .idea # Packages/installer info *.egg *.egg-info dist build eggs .eggs parts var sdist develop-eggs .installed.cfg distribute-*.tar.gz pip-wheel-metadata # Other .*.swp *~ # Mac OSX .DS_Store # setuptools-scm generated version file src/pytest_asdf_plugin/_version.py # airspeed velocity files .asv # hypothesis files .hypothesis asdf-format-pytest-asdf-plugin-249fefe/.pre-commit-config.yaml000066400000000000000000000026161505066657000244600ustar00rootroot00000000000000repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 hooks: - id: check-added-large-files - id: check-ast - id: check-case-conflict - id: check-yaml args: ["--unsafe"] exclude: "tests/example/error-1.0.0" - id: check-toml - id: check-merge-conflict - id: check-symlinks - id: debug-statements - id: detect-private-key - id: end-of-file-fixer exclude: ".*fits" - id: trailing-whitespace exclude: ".*fits" - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 hooks: - id: python-check-blanket-noqa - id: python-check-mock-methods - id: rst-directive-colons - id: rst-inline-touching-normal - id: text-unicode-replacement-char - repo: https://github.com/codespell-project/codespell rev: v2.4.1 hooks: - id: codespell args: ["--write-changes"] additional_dependencies: - tomli - repo: https://github.com/ikamensh/flynt/ rev: '1.0.1' hooks: - id: flynt - repo: https://github.com/astral-sh/ruff-pre-commit rev: 'v0.11.6' hooks: - id: ruff args: ["--fix"] - repo: https://github.com/psf/black rev: 25.1.0 hooks: - id: black - repo: https://github.com/asottile/blacken-docs rev: '1.19.1' hooks: - id: blacken-docs - repo: https://github.com/abravalheri/validate-pyproject rev: "v0.24.1" hooks: - id: validate-pyproject asdf-format-pytest-asdf-plugin-249fefe/README.rst000066400000000000000000000012111505066657000216540ustar00rootroot00000000000000pytest-asdf-plugin ================== pytest plugin for testing ASDF schemas. License ------- ASDF is licensed under a BSD 3-clause style license. See `LICENSE.rst `_ for the `licenses folder `_ for licenses for any included software. Contributing ------------ We welcome feedback and contributions to the project. Contributions of code, documentation, or general feedback are all appreciated. Please follow the `contributing guidelines `__ to submit an issue or a pull request. We strive to provide a welcoming community to all of our users by abiding to the `Code of Conduct `__. asdf-format-pytest-asdf-plugin-249fefe/pyproject.toml000066400000000000000000000037101505066657000231070ustar00rootroot00000000000000[project] name = "pytest-asdf-plugin" description = "Pytest plugin for testing ASDF schemas" readme = 'README.rst' license-files = ['LICENSE'] authors = [{ name = 'The ASDF Developers', email = 'help@stsci.edu' }] requires-python = '>=3.9' classifiers = [ 'Development Status :: 5 - Production/Stable', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Framework :: Pytest', ] dynamic = [ 'version', ] dependencies = [ "asdf", "pytest>=7", ] [project.urls] 'documentation' = 'https://pytest-asdf-plugin.readthedocs.io/en/stable/' 'repository' = 'https://github.com/asdf-format/pytest-asdf-plugin' 'tracker' = 'https://github.com/asdf-format/pytest-asdf-plugin/issues' [project.entry-points] pytest11 = {pytest_asdf_plugin = 'pytest_asdf_plugin.plugin'} [build-system] build-backend = 'setuptools.build_meta' requires = [ "setuptools>=60", "setuptools_scm[toml]>=8", "wheel", ] [tool.setuptools_scm] version_file = "src/pytest_asdf_plugin/_version.py" [tool.black] line-length = 120 force-exclude = ''' ^/( ( \.eggs | \.git | \.pytest_cache | \.tox | asdf/_extern | asdf/_jsonschema | build | dist )/ ) ''' [tool.pytest.ini_options] pytester_example_dir = 'tests' testpaths = ['tests'] minversion = 4.6 filterwarnings = [ 'error', ] addopts = [ # numpy does not like the reimports done by pytester # so run pytester in a subprocess '--runpytest=subprocess', '--color=yes', '-rsxfE', '-p no:legacypath', ] [tool.ruff] target-version = "py38" line-length = 120 [tool.ruff.lint] select = [ # minimal set to match pre-ruff behavior "E", # pycodestyle "F", # pyflakes, autoflake "I", # isort "S", # bandit "UP", # pyupgrade "RUF", # ruff specific, includes yesqa ] extend-ignore = [ "S310", # URL open for permitted schemes "RUF012", # mutable-class-default (typing related) ] [tool.codespell] skip="*.pdf,*.asdf,.tox,build,.git,docs/_build" asdf-format-pytest-asdf-plugin-249fefe/src/000077500000000000000000000000001505066657000207615ustar00rootroot00000000000000asdf-format-pytest-asdf-plugin-249fefe/src/pytest_asdf_plugin/000077500000000000000000000000001505066657000246645ustar00rootroot00000000000000asdf-format-pytest-asdf-plugin-249fefe/src/pytest_asdf_plugin/__init__.py000066400000000000000000000000001505066657000267630ustar00rootroot00000000000000asdf-format-pytest-asdf-plugin-249fefe/src/pytest_asdf_plugin/plugin.py000066400000000000000000000221651505066657000265420ustar00rootroot00000000000000import os import pathlib from dataclasses import dataclass from importlib.metadata import version import pytest import yaml # check if the asdf version has the required check for # the non-bunbled pytest plugin (this package) HAS_PLUGIN_CHECK = version("asdf") >= "4.4.0" def pytest_addoption(parser): if not HAS_PLUGIN_CHECK: return parser.addini("asdf_schema_root", "Root path indicating where schemas are stored") parser.addini("asdf_schema_skip_names", "Base names of files to skip in schema tests") parser.addini( "asdf_schema_skip_tests", "List of tests to skip, one per line, in format ::", ) parser.addini( "asdf_schema_xfail_tests", "List of tests to xfail, one per line, in format ::", ) parser.addini("asdf_schema_skip_examples", "Base names of schemas whose examples should not be tested") parser.addini( "asdf_schema_tests_enabled", "Controls whether schema tests are enabled by default", type="bool", default=False, ) parser.addini( "asdf_schema_validate_default", "Set to true to enable validation of the schema 'default' property", type="bool", default=True, ) parser.addini( "asdf_schema_ignore_unrecognized_tag", "Set to true to disable warnings when tag serializers are missing", type="bool", default=False, ) parser.addoption("--asdf-tests", action="store_true", help="Enable ASDF schema tests") class AsdfSchemaFile(pytest.File): @classmethod def from_parent( cls, parent, *, fspath, skip_examples=False, validate_default=True, ignore_unrecognized_tag=False, skip_tests=None, xfail_tests=None, **kwargs, ): path = pathlib.Path(fspath) kwargs["path"] = path if hasattr(super(), "from_parent"): result = super().from_parent(parent, **kwargs) else: result = AsdfSchemaFile(path, parent) result.skip_examples = skip_examples result.validate_default = validate_default result.ignore_unrecognized_tag = ignore_unrecognized_tag result.skip_tests = [] if skip_tests is None else skip_tests result.xfail_tests = [] if xfail_tests is None else xfail_tests return result def _set_markers(self, item): if item.name in self.skip_tests or "*" in self.skip_tests: item.add_marker(pytest.mark.skip) if item.name in self.xfail_tests or "*" in self.xfail_tests: item.add_marker(pytest.mark.xfail) def collect(self): item = AsdfSchemaItem.from_parent(self, self.fspath, validate_default=self.validate_default, name="test_schema") self._set_markers(item) yield item if not self.skip_examples: for index, example in enumerate(self.find_examples_in_schema()): name = f"test_example_{index}" item = AsdfSchemaExampleItem.from_parent( self, self.fspath, example, index, ignore_unrecognized_tag=self.ignore_unrecognized_tag, name=name, ) self._set_markers(item) yield item def find_examples_in_schema(self): """Returns generator for all examples in schema at given path""" from asdf import treeutil with open(str(self.fspath), "rb") as fd: schema_tree = yaml.safe_load(fd) for node in treeutil.iter_tree(schema_tree): if isinstance(node, dict) and "examples" in node and isinstance(node["examples"], list): yield from node["examples"] class AsdfSchemaItem(pytest.Item): @classmethod def from_parent(cls, parent, schema_path, validate_default=True, **kwargs): if hasattr(super(), "from_parent"): result = super().from_parent(parent, **kwargs) else: name = kwargs.pop("name") result = AsdfSchemaItem(name, parent, **kwargs) result.schema_path = schema_path result.validate_default = validate_default return result def runtest(self): from asdf import schema # Make sure that each schema itself is valid. schema_tree = schema.load_schema( self.schema_path, resolve_references=True, ) schema.check_schema(schema_tree, validate_default=self.validate_default) def reportinfo(self): return self.fspath, 0, "" @dataclass class SchemaExample: description: str example: str _version: str = None other: any = None @classmethod def from_schema(cls, example: list): if len(example) == 1: _description = "" _example = example[0] elif len(example) == 2: _description = example[0] _example = example[1] _version = None _other = None elif len(example) > 2: _description = example[0] _example = example[2] _version = example[1] _other = example[3:] if len(example) > 3 else None else: msg = "Invalid example" raise RuntimeError(msg) return cls(_description, _example, _version, _other) @property def version(self): from asdf import versioning if self._version is None: return versioning.default_version version = self._version.lower().split("asdf-standard-")[1] return versioning.AsdfVersion(version) class AsdfSchemaExampleItem(pytest.Item): @classmethod def from_parent( cls, parent, schema_path, example, example_index, ignore_unrecognized_tag=False, **kwargs, ): if hasattr(super(), "from_parent"): result = super().from_parent(parent, **kwargs) else: name = kwargs.pop("name") result = AsdfSchemaExampleItem(name, parent, **kwargs) result.filename = str(schema_path) result.example = SchemaExample.from_schema(example) result.ignore_unrecognized_tag = ignore_unrecognized_tag return result def runtest(self): import asdf from asdf.testing.helpers import yaml_to_asdf # check the example is valid buff = yaml_to_asdf("example: " + self.example.example.strip(), version=self.example.version) tagged_tree = asdf.util.load_yaml(buff, tagged=True) instance = asdf.AsdfFile(version=self.example.version) asdf.schema.validate(tagged_tree, instance, reading=True) def reportinfo(self): return self.fspath, 0, "" def _parse_test_list(content): result = {} if isinstance(content, str): content = content.split("\n") for line in content: line_ = line.strip() if len(line_) > 0: parts = line_.split("::", 1) path_suffix = pathlib.Path(parts[0]).as_posix() name = "*" if len(parts) == 1 else parts[-1] if path_suffix not in result: result[path_suffix] = [] result[path_suffix].append(name) return result def pytest_collect_file(file_path, parent): if not HAS_PLUGIN_CHECK: return if not (parent.config.getini("asdf_schema_tests_enabled") or parent.config.getoption("asdf_tests")): return None schema_roots = parent.config.getini("asdf_schema_root").split() if not schema_roots: return None skip_names = parent.config.getini("asdf_schema_skip_names") skip_examples = parent.config.getini("asdf_schema_skip_examples") validate_default = parent.config.getini("asdf_schema_validate_default") ignore_unrecognized_tag = parent.config.getini("asdf_schema_ignore_unrecognized_tag") skip_tests = _parse_test_list(parent.config.getini("asdf_schema_skip_tests")) xfail_tests = _parse_test_list(parent.config.getini("asdf_schema_xfail_tests")) schema_roots = [os.path.join(str(parent.config.rootpath), os.path.normpath(root)) for root in schema_roots] if file_path.suffix != ".yaml": return None for root in schema_roots: 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): schema_skip_tests.extend(names) schema_xfail_tests = [] for suffix, names in xfail_tests.items(): if posix_path.endswith(suffix): schema_xfail_tests.extend(names) return AsdfSchemaFile.from_parent( parent, fspath=file_path, skip_examples=(file_path.stem in skip_examples), validate_default=validate_default, ignore_unrecognized_tag=ignore_unrecognized_tag, skip_tests=schema_skip_tests, xfail_tests=schema_xfail_tests, ) return None asdf-format-pytest-asdf-plugin-249fefe/tests/000077500000000000000000000000001505066657000213345ustar00rootroot00000000000000asdf-format-pytest-asdf-plugin-249fefe/tests/__init__.py000066400000000000000000000000001505066657000234330ustar00rootroot00000000000000asdf-format-pytest-asdf-plugin-249fefe/tests/conftest.py000066400000000000000000000000361505066657000235320ustar00rootroot00000000000000pytest_plugins = ["pytester"] asdf-format-pytest-asdf-plugin-249fefe/tests/example/000077500000000000000000000000001505066657000227675ustar00rootroot00000000000000asdf-format-pytest-asdf-plugin-249fefe/tests/example/error-1.0.0.yaml000066400000000000000000000003711505066657000254370ustar00rootroot00000000000000%YAML 1.1 --- $schema: "http://stsci.edu/schemas/yaml-schema/draft-01" id: "asdf://asdf-format.org/pytest_asdf_plugin/schemas/error-1.0.0" title: An invalid yaml file. This is outside the resources path so should never be loaded. - examples: error asdf-format-pytest-asdf-plugin-249fefe/tests/example/resources/000077500000000000000000000000001505066657000250015ustar00rootroot00000000000000asdf-format-pytest-asdf-plugin-249fefe/tests/example/resources/schemas/000077500000000000000000000000001505066657000264245ustar00rootroot00000000000000asdf-format-pytest-asdf-plugin-249fefe/tests/example/resources/schemas/failing-1.0.0.yaml000066400000000000000000000006531505066657000313570ustar00rootroot00000000000000%YAML 1.1 --- $schema: "http://stsci.edu/schemas/yaml-schema/draft-01" id: "asdf://asdf-format.org/pytest_asdf_plugin/schemas/failing-1.0.0" title: A test schema with a few failing examples examples: - - "First example - invalid" - asdf-standard-1.6.0 - | !core/integer-1.1.0 a - - "Second example - invalid" - asdf-standard-1.5.0 - | !core/integer-1.0.0 b ... asdf-format-pytest-asdf-plugin-249fefe/tests/example/resources/schemas/invalid-1.0.0.yaml000066400000000000000000000003231505066657000313660ustar00rootroot00000000000000%YAML 1.1 --- $schema: "http://stsci.edu/schemas/yaml-schema/draft-01" id: "asdf://asdf-format.org/pytest_asdf_plugin/schemas/invalid-1.0.0" title: An invalid schema properties: - "should not be a list" ... asdf-format-pytest-asdf-plugin-249fefe/tests/example/resources/schemas/nested/000077500000000000000000000000001505066657000277065ustar00rootroot00000000000000asdf-format-pytest-asdf-plugin-249fefe/tests/example/resources/schemas/nested/nested-1.0.0.yaml000066400000000000000000000012301505066657000325020ustar00rootroot00000000000000%YAML 1.1 --- $schema: "http://stsci.edu/schemas/yaml-schema/draft-01" id: "asdf://asdf-format.org/pytest_asdf_plugin/schemas/nested-1.0.0" title: A test schema with a few examples examples: - - "First example - valid" - | !core/ndarray-1.0.0 [[1, 0, 0], [0, 1, 0], [0, 0, 1]] - - "Second example - valid" - asdf-standard-1.5.0 - | !core/ndarray-1.0.0 [[1, 0, 0], [0, 1, 0], [0, 0, 1]] - - "Third example - missing tag" - asdf-standard-1.6.0 - | !core/ndarray-1.0.0 [[1, 0, 0], [0, 1, 0], [0, 0, 1]] ... asdf-format-pytest-asdf-plugin-249fefe/tests/example/resources/schemas/passing-1.0.0.yaml000066400000000000000000000012311505066657000314030ustar00rootroot00000000000000%YAML 1.1 --- $schema: "http://stsci.edu/schemas/yaml-schema/draft-01" id: "asdf://asdf-format.org/pytest_asdf_plugin/schemas/passing-1.0.0" title: A test schema with a few examples examples: - - "First example - valid" - | !core/ndarray-1.0.0 [[1, 0, 0], [0, 1, 0], [0, 0, 1]] - - "Second example - valid" - asdf-standard-1.5.0 - | !core/ndarray-1.0.0 [[1, 0, 0], [0, 1, 0], [0, 0, 1]] - - "Third example - missing tag" - asdf-standard-1.6.0 - | !core/ndarray-1.0.0 [[1, 0, 0], [0, 1, 0], [0, 0, 1]] ... asdf-format-pytest-asdf-plugin-249fefe/tests/test_plugin.py000066400000000000000000000072451505066657000242530ustar00rootroot00000000000000import pytest # the example schemas have a number of successes and failures # hard-code them here to allow more flexibility in the tests below PASSES = 9 FAILURES = 3 def test_pyprojecttoml(pytester): pytester.copy_example("example") pytester.makepyprojecttoml( """ [tool.pytest.ini_options] asdf_schema_root = 'resources/schemas' asdf_schema_tests_enabled = 'true' asdf_schema_ignore_unrecognized_tag = 'true' """ ) result = pytester.runpytest() result.assert_outcomes(passed=PASSES, failed=FAILURES) def test_asdf_tests_argument(pytester): pytester.copy_example("example") pytester.makepyprojecttoml( """ [tool.pytest.ini_options] asdf_schema_root = 'resources/schemas' asdf_schema_ignore_unrecognized_tag = 'true' """ ) result = pytester.runpytest("--asdf-tests") result.assert_outcomes(passed=PASSES, failed=FAILURES) @pytest.mark.parametrize( "skip_cfg, passes, failures", (("passing-1.0.0", PASSES - 3, FAILURES),), ) def test_skip_examples(pytester, skip_cfg, passes, failures): pytester.copy_example("example") pytester.makepyprojecttoml( f""" [tool.pytest.ini_options] asdf_schema_root = 'resources/schemas' asdf_schema_tests_enabled = 'true' asdf_schema_ignore_unrecognized_tag = 'true' asdf_schema_skip_examples = "{skip_cfg}" """ ) result = pytester.runpytest() result.assert_outcomes(passed=passes, failed=failures) @pytest.mark.parametrize( "skip_cfg, passes, failures", (("passing-1.0.0", PASSES - 4, FAILURES),), ) def test_skip_names(pytester, skip_cfg, passes, failures): pytester.copy_example("example") pytester.makepyprojecttoml( f""" [tool.pytest.ini_options] asdf_schema_root = 'resources/schemas' asdf_schema_tests_enabled = 'true' asdf_schema_ignore_unrecognized_tag = 'true' asdf_schema_skip_names = "{skip_cfg}" """ ) result = pytester.runpytest() result.assert_outcomes(passed=passes, failed=failures) @pytest.mark.parametrize( "skip_cfg, passes, failures, skips", ( ("passing-1.0.0.yaml", PASSES - 4, FAILURES, 4), ("passing-1.0.0.yaml::*", PASSES - 4, FAILURES, 4), ("passing-1.0.0.yaml::test_example_0", PASSES - 1, FAILURES, 1), ("passing-1.0.0.yaml::test_example_1", PASSES - 1, FAILURES, 1), ("nested/nested-1.0.0.yaml", PASSES - 4, FAILURES, 4), ), ) def test_skips(pytester, skip_cfg, passes, failures, skips): pytester.copy_example("example") pytester.makepyprojecttoml( f""" [tool.pytest.ini_options] asdf_schema_root = 'resources/schemas' asdf_schema_tests_enabled = 'true' asdf_schema_ignore_unrecognized_tag = 'true' asdf_schema_skip_tests = "{skip_cfg}" """ ) result = pytester.runpytest() result.assert_outcomes(passed=passes, failed=failures, skipped=skips) @pytest.mark.parametrize( "xfail_cfg, xpasses, xfailures", ( ("passing-1.0.0.yaml", 4, 0), ("passing-1.0.0.yaml::*", 4, 0), ("failing-1.0.0.yaml", 1, 2), ), ) def test_xfail(pytester, xfail_cfg, xpasses, xfailures): pytester.copy_example("example") pytester.makepyprojecttoml( f""" [tool.pytest.ini_options] asdf_schema_root = 'resources/schemas' asdf_schema_tests_enabled = 'true' asdf_schema_ignore_unrecognized_tag = 'true' asdf_schema_xfail_tests = "{xfail_cfg}" """ ) result = pytester.runpytest() result.assert_outcomes(passed=PASSES - xpasses, failed=FAILURES - xfailures, xpassed=xpasses, xfailed=xfailures) asdf-format-pytest-asdf-plugin-249fefe/tox.ini000066400000000000000000000064401505066657000215110ustar00rootroot00000000000000[tox] env_list = # Everything should work for python 39 310 311 but the pytester plugin # used to test this plugin loses this plugin after the first test run. py{312,313}{,-coverage}{,-pytestdev}{,-oldasdf} downstream-{standard,transform,wcs,coordinates,astropy,rad,stdatamodels,sunpy,dkist,weldx} [testenv] deps = coverage: coverage pytestdev: git+https://github.com/pytest-dev/pytest # Install a version of asdf that doesn't have any checks for this new pytest plugin # This should result in the test suite in this package running using the plugin # that is bundled with asdf. At the moment the goal is to make everything pass # for both plugins (to show this external package plugin is the same). At some point # we will add new features and tests here that will require either removing this # test or skipping some tests for old asdf versions. oldasdf: asdf==4.3.0 extras = all,tests package = editable commands_pre = pip freeze # coverage run must be used because the pytest-asdf plugin will interfere # with proper coverage measurement due to the order pytest loads its # entry points. commands = coverage: coverage run --source=pytest-asdf-plugin --rcfile={tox_root}/pyproject.toml -m \ pytest \ --durations=10 \ # the OpenAstronomy workflow appends `--cov-report` in `{posargs}`, which `coverage` doesn't recognize !coverage: {posargs} coverage: coverage: coverage xml -o {tox_root}/coverage.xml coverage: coverage report [testenv:downstream-{standard,transform,wcs,coordinates,astropy,rad,stdatamodels,sunpy,dkist,weldx}] change_dir = {env_tmp_dir} allowlist_externals = git bash commands_pre = rad: git clone https://github.com/spacetelescope/rad.git . dkist: git clone https://github.com/DKISTDC/dkist.git . bash -c "pip freeze -q | grep 'pytest-asdf-plugin @' > {env_tmp_dir}/_asdf_requirements.txt" standard: git clone https://github.com/asdf-format/asdf-standard.git standard: pip install ./asdf-standard[test] transform: git clone https://github.com/asdf-format/asdf-transform-schemas.git transform: pip install ./asdf-transform-schemas[test] wcs: git clone https://github.com/asdf-format/asdf-wcs-schemas.git wcs: pip install ./asdf-wcs-schemas[test] coordinates: git clone https://github.com/asdf-format/asdf-coordinates-schemas.git coordinates: pip install ./asdf-coordinates-schemas[test] astropy: git clone https://github.com/astropy/asdf-astropy.git astropy: pip install ./asdf-astropy[test] rad: pip install -e .[test] stdatamodels: git clone https://github.com/spacetelescope/stdatamodels.git stdatamodels: pip install ./stdatamodels[test] sunpy: git clone https://github.com/sunpy/sunpy.git sunpy: pip install -e ./sunpy[tests,all] dkist: pip install .[tests] weldx: git clone https://github.com/BAMWelDX/weldx.git weldx: pip install weldx[test,media] pip install -r {env_tmp_dir}/_asdf_requirements.txt pip freeze commands = pytest \ standard: asdf-standard transform: asdf-transform-schemas wcs: asdf-wcs-schemas coordinates: asdf-coordinates-schemas astropy: asdf-astropy rad: . stdatamodels: stdatamodels --no-crds sunpy: sunpy/sunpy/io dkist: --benchmark-skip weldx: weldx/weldx/tests/asdf_tests weldx/weldx/schemas --asdf-tests