Skip to content

Commit

Permalink
Backport PR asdf-format#1388: Deprecate/assert extension correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram authored and meeseeksmachine committed Feb 21, 2023
1 parent 475acf3 commit 7131ec0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The ASDF Standard is at v1.6.0
writing ASDF in fits files is being moved to `stdatamodels
<https://github.com/spacetelescope/stdatamodels>`_. [#1337]
- Add AsdfDeprecationWarning to asdf.resolver [#1362]
- Add AsdfDeprecationWarning to asdf.tests.helpers.assert_extension_correctness [#1388]

2.14.3 (2022-12-15)
-------------------
Expand Down
10 changes: 9 additions & 1 deletion asdf/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from asdf.asdf import AsdfFile, get_asdf_library_info
from asdf.block import Block
from asdf.constants import YAML_TAG_PREFIX
from asdf.exceptions import AsdfConversionWarning
from asdf.exceptions import AsdfConversionWarning, AsdfDeprecationWarning
from asdf.extension import default_extensions
from asdf.tags.core import AsdfObject
from asdf.versioning import (
Expand Down Expand Up @@ -421,6 +421,14 @@ def assert_extension_correctness(extension):
# exposing it as asdf.tests.helpers.Resolver/ResolverChain
from asdf._resolver import Resolver, ResolverChain

warnings.warn(
"assert_extension_correctness is deprecated and depends "
"on the deprecated type system. Please use the new "
"extension API: "
"https://asdf.readthedocs.io/en/stable/asdf/extending/converters.html",
AsdfDeprecationWarning,
)

resolver = ResolverChain(
Resolver(extension.tag_mapping, "tag"),
Resolver(extension.url_mapping, "url"),
Expand Down
8 changes: 8 additions & 0 deletions asdf/tests/test_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import pytest

from asdf.exceptions import AsdfDeprecationWarning
from asdf.tests.helpers import assert_extension_correctness
from asdf.tests.objects import CustomExtension
from asdf.types import CustomType


Expand All @@ -27,3 +29,9 @@ def test_resolver_module_deprecation():
if "asdf.resolver" in sys.modules:
del sys.modules["asdf.resolver"]
import asdf.resolver # noqa: F401


def test_assert_extension_correctness_deprecation():
extension = CustomExtension()
with pytest.warns(AsdfDeprecationWarning, match="assert_extension_correctness is deprecated.*"):
assert_extension_correctness(extension)
3 changes: 2 additions & 1 deletion asdf/tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

def test_builtin_extension():
extension = BuiltinExtension()
assert_extension_correctness(extension)
with pytest.warns(AsdfDeprecationWarning, match="assert_extension_correctness is deprecated.*"):
assert_extension_correctness(extension)


with pytest.warns(AsdfDeprecationWarning, match=".*subclasses the deprecated CustomType.*"):
Expand Down

0 comments on commit 7131ec0

Please sign in to comment.