Skip to content

Commit 5985cae

Browse files
authored
Merge pull request #1957 from braingram/deprecate_pytest_asdf
Check for external pytest-asdf-plugin and don't register bundled plugin if the external one exists
2 parents c6b24a5 + 5f74638 commit 5985cae

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

pytest_asdf/plugin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import importlib
12
import os
23
import pathlib
34
from dataclasses import dataclass
@@ -6,9 +7,12 @@
67
import yaml
78

89
# Avoid all imports of asdf at this level in order to avoid circular imports
10+
HAS_NEW_PLUGIN = importlib.util.find_spec("pytest_asdf_plugin") is not None
911

1012

1113
def pytest_addoption(parser):
14+
if HAS_NEW_PLUGIN:
15+
return
1216
parser.addini("asdf_schema_root", "Root path indicating where schemas are stored")
1317
parser.addini("asdf_schema_skip_names", "Base names of files to skip in schema tests")
1418
parser.addini(
@@ -200,6 +204,9 @@ def runtest(self):
200204
import asdf
201205
from asdf.testing.helpers import yaml_to_asdf
202206

207+
# warn inside test, we don't do this yet to allow time for downstream packages to adopt pytest-asdf-plugin
208+
# warnings.warn("pytest_asdf is deprecated, install pytest_asdf_plugin instead", DeprecationWarning)
209+
203210
# check the example is valid
204211
buff = yaml_to_asdf("example: " + self.example.example.strip(), version=self.example.version)
205212
tagged_tree = asdf.util.load_yaml(buff, tagged=True)
@@ -233,6 +240,8 @@ def _parse_test_list(content):
233240

234241

235242
def pytest_collect_file(file_path, parent):
243+
if HAS_NEW_PLUGIN:
244+
return None
236245
if not (parent.config.getini("asdf_schema_tests_enabled") or parent.config.getoption("asdf_tests")):
237246
return None
238247

0 commit comments

Comments
 (0)