fix key conversion on legacy JSON profiles (#85253)

* fix key conversion on legacy JSON profiles

* restore stdlib silent str conversion behavior for int/float/bool/None dict key types
* remove most conversions for non-scalar keys
* add key conversion cases to JSON profile test suite

* typo

* Fix sanity test failures

* Fix _handle_key_str_fallback implementation

---------

Co-authored-by: Matt Clay <matt@mystile.com>
pull/81511/head
Matt Davis 6 months ago committed by GitHub
parent d7c4d0119f
commit bbbfbd57e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -46,6 +46,8 @@ class _Profile(_profiles._JSONSerializationProfile):
_datetime.datetime: _datatag.AnsibleSerializableDateTime,
}
cls.handle_key = cls._handle_key_str_fallback # legacy stdlib-compatible key behavior
class Encoder(_profiles.AnsibleProfileJSONEncoder):
_profile = _Profile

@ -152,6 +152,8 @@ class _Profile(_profiles._JSONSerializationProfile["Encoder", "Decoder"]):
'__ansible_vault': cls.deserialize_vault,
}
cls.handle_key = cls._handle_key_str_fallback # type: ignore[method-assign] # legacy stdlib-compatible key behavior
@classmethod
def pre_serialize(cls, encoder: Encoder, o: _t.Any) -> _t.Any:
# DTFIX7: these conversion args probably aren't needed
@ -165,16 +167,6 @@ class _Profile(_profiles._JSONSerializationProfile["Encoder", "Decoder"]):
return avv.visit(o)
@classmethod
def handle_key(cls, k: _t.Any) -> _t.Any:
if isinstance(k, str):
return k
# DTFIX3: decide if this is a deprecation warning, error, or what?
# Non-string variable names have been disallowed by set_fact and other things since at least 2021.
# DTFIX5: document why this behavior is here, also verify the legacy tagless use case doesn't need this same behavior
return str(k)
class Encoder(_profiles.AnsibleProfileJSONEncoder):
_profile = _Profile

@ -204,6 +204,7 @@ class _JSONSerializationProfile(t.Generic[_T_encoder, _T_decoder]):
@classmethod
def handle_key(cls, k: t.Any) -> t.Any:
"""Validation/conversion hook before a dict key is serialized. The default implementation only accepts str-typed keys."""
# NOTE: Since JSON requires string keys, there is no support for preserving tags on dictionary keys during serialization.
if not isinstance(k, str): # DTFIX-FUTURE: optimize this to use all known str-derived types in type map / allowed types
@ -211,6 +212,19 @@ class _JSONSerializationProfile(t.Generic[_T_encoder, _T_decoder]):
return k
@classmethod
def _handle_key_str_fallback(cls, k: t.Any) -> t.Any:
"""Legacy implementations should use this key handler for backward compatibility with stdlib JSON key conversion quirks."""
# DTFIX-FUTURE: optimized exact-type table lookup first
if isinstance(k, str):
return k
if k is None or isinstance(k, (int, float)):
return json.dumps(k)
raise TypeError(f'Key of type {type(k).__name__!r} is not JSON serializable by the {cls.profile_name!r} profile.')
@classmethod
def default(cls, o: t.Any) -> t.Any:
# Preserve the built-in JSON encoder support for subclasses of scalar types.

@ -22,6 +22,8 @@ class _Profile(_profiles._JSONSerializationProfile["Encoder", "Decoder"]):
}
)
cls.handle_key = cls._handle_key_str_fallback # type: ignore[method-assign] # legacy stdlib-compatible key behavior
class Encoder(_profiles.AnsibleProfileJSONEncoder):
_profile = _Profile

@ -26,6 +26,8 @@ class _Profile(_profiles._JSONSerializationProfile["Encoder", "Decoder"]):
_datetime.datetime: cls.serialize_as_isoformat, # legacy _json_encode_fallback behavior *and* legacy parameters.py does this before serialization
}
cls.handle_key = cls._handle_key_str_fallback # type: ignore[method-assign] # legacy stdlib-compatible key behavior
class Encoder(_profiles.AnsibleProfileJSONEncoder):
_profile = _Profile

@ -41,6 +41,8 @@ class _Profile(_profiles._JSONSerializationProfile["Encoder", "Decoder"]):
'__ansible_vault': _functools.partial(cls.unsupported_target_type_error, '__ansible_vault'),
}
cls.handle_key = cls._handle_key_str_fallback # type: ignore[method-assign] # legacy stdlib-compatible key behavior
class Encoder(_profiles.AnsibleProfileJSONEncoder):
_profile = _Profile

@ -49,4 +49,20 @@ _TestParameters(profile_name='cache_persistence', value={frozenset({1, 2}): 'thr
_TestParameters(profile_name='cache_persistence', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'), TrustedAsTemplate(), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), VaultedValue(ciphertext='x'), SourceWasEncrypted())): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'cache_persistence' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='cache_persistence', value={frozenset({1, 2}): 'three'}, lazy=True): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'cache_persistence' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='cache_persistence', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'), TrustedAsTemplate(), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), VaultedValue(ciphertext='x'), SourceWasEncrypted()), lazy=True): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'cache_persistence' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='cache_persistence', value={1: 'two'}): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='cache_persistence', value={1: 'two'}, tags=(Deprecated(msg='x'), TrustedAsTemplate(), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), VaultedValue(ciphertext='x'), SourceWasEncrypted())): _TestOutput(payload='{"value": {"1": "two"}, "tags": [{"msg": "x", "__ansible_type": "Deprecated"}, {"__ansible_type": "TrustedAsTemplate"}, {"path": "/tmp/x", "description": "y", "line_num": 1, "col_num": 2, "__ansible_type": "Origin"}, {"ciphertext": "x", "__ansible_type": "VaultedValue"}, {"__ansible_type": "SourceWasEncrypted"}], "__ansible_type": "_AnsibleTaggedDict"}', round_trip={'1': 'two'}, tags=(Deprecated(msg='x'), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), SourceWasEncrypted(), TrustedAsTemplate(), VaultedValue(ciphertext='x'))),
_TestParameters(profile_name='cache_persistence', value={1: 'two'}, lazy=True): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='cache_persistence', value={1: 'two'}, tags=(Deprecated(msg='x'), TrustedAsTemplate(), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), VaultedValue(ciphertext='x'), SourceWasEncrypted()), lazy=True): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='cache_persistence', value={1.1: 'two'}): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='cache_persistence', value={1.1: 'two'}, tags=(Deprecated(msg='x'), TrustedAsTemplate(), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), VaultedValue(ciphertext='x'), SourceWasEncrypted())): _TestOutput(payload='{"value": {"1.1": "two"}, "tags": [{"msg": "x", "__ansible_type": "Deprecated"}, {"__ansible_type": "TrustedAsTemplate"}, {"path": "/tmp/x", "description": "y", "line_num": 1, "col_num": 2, "__ansible_type": "Origin"}, {"ciphertext": "x", "__ansible_type": "VaultedValue"}, {"__ansible_type": "SourceWasEncrypted"}], "__ansible_type": "_AnsibleTaggedDict"}', round_trip={'1.1': 'two'}, tags=(Deprecated(msg='x'), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), SourceWasEncrypted(), TrustedAsTemplate(), VaultedValue(ciphertext='x'))),
_TestParameters(profile_name='cache_persistence', value={1.1: 'two'}, lazy=True): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='cache_persistence', value={1.1: 'two'}, tags=(Deprecated(msg='x'), TrustedAsTemplate(), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), VaultedValue(ciphertext='x'), SourceWasEncrypted()), lazy=True): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='cache_persistence', value={True: 'two'}): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='cache_persistence', value={True: 'two'}, tags=(Deprecated(msg='x'), TrustedAsTemplate(), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), VaultedValue(ciphertext='x'), SourceWasEncrypted())): _TestOutput(payload='{"value": {"true": "two"}, "tags": [{"msg": "x", "__ansible_type": "Deprecated"}, {"__ansible_type": "TrustedAsTemplate"}, {"path": "/tmp/x", "description": "y", "line_num": 1, "col_num": 2, "__ansible_type": "Origin"}, {"ciphertext": "x", "__ansible_type": "VaultedValue"}, {"__ansible_type": "SourceWasEncrypted"}], "__ansible_type": "_AnsibleTaggedDict"}', round_trip={'true': 'two'}, tags=(Deprecated(msg='x'), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), SourceWasEncrypted(), TrustedAsTemplate(), VaultedValue(ciphertext='x'))),
_TestParameters(profile_name='cache_persistence', value={True: 'two'}, lazy=True): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='cache_persistence', value={True: 'two'}, tags=(Deprecated(msg='x'), TrustedAsTemplate(), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), VaultedValue(ciphertext='x'), SourceWasEncrypted()), lazy=True): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='cache_persistence', value={None: 'two'}): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='cache_persistence', value={None: 'two'}, tags=(Deprecated(msg='x'), TrustedAsTemplate(), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), VaultedValue(ciphertext='x'), SourceWasEncrypted())): _TestOutput(payload='{"value": {"null": "two"}, "tags": [{"msg": "x", "__ansible_type": "Deprecated"}, {"__ansible_type": "TrustedAsTemplate"}, {"path": "/tmp/x", "description": "y", "line_num": 1, "col_num": 2, "__ansible_type": "Origin"}, {"ciphertext": "x", "__ansible_type": "VaultedValue"}, {"__ansible_type": "SourceWasEncrypted"}], "__ansible_type": "_AnsibleTaggedDict"}', round_trip={'null': 'two'}, tags=(Deprecated(msg='x'), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), SourceWasEncrypted(), TrustedAsTemplate(), VaultedValue(ciphertext='x'))),
_TestParameters(profile_name='cache_persistence', value={None: 'two'}, lazy=True): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='cache_persistence', value={None: 'two'}, tags=(Deprecated(msg='x'), TrustedAsTemplate(), Origin(path='/tmp/x', description='y', line_num=1, col_num=2), VaultedValue(ciphertext='x'), SourceWasEncrypted()), lazy=True): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
}

@ -49,6 +49,22 @@ _TestParameters(profile_name='fallback_to_str', value={frozenset({1, 2}): 'three
_TestParameters(profile_name='fallback_to_str', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"[1, 2]": "three"}', round_trip={'[1, 2]': 'three'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={frozenset({1, 2}): 'three'}, lazy=True): _TestOutput(payload='{"[1, 2]": "three"}', round_trip={'[1, 2]': 'three'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"[1, 2]": "three"}', round_trip={'[1, 2]': 'three'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={1: 'two'}): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={1: 'two'}, lazy=True): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={1: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={1.1: 'two'}): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={1.1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={1.1: 'two'}, lazy=True): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={1.1: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={True: 'two'}): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={True: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={True: 'two'}, lazy=True): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={True: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={None: 'two'}): _TestOutput(payload='{"None": "two"}', round_trip={'None': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={None: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"None": "two"}', round_trip={'None': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={None: 'two'}, lazy=True): _TestOutput(payload='{"None": "two"}', round_trip={'None': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value={None: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"None": "two"}', round_trip={'None': 'two'}, tags=()),
_TestParameters(profile_name='fallback_to_str', value=b'\x00'): _TestOutput(payload='"\\u0000"', round_trip='\x00', tags=()),
_TestParameters(profile_name='fallback_to_str', value=b'\x00', tags=(Deprecated(msg='x'),)): _TestOutput(payload='"\\u0000"', round_trip='\x00', tags=()),
_TestParameters(profile_name='fallback_to_str', value=b'\x80'): _TestOutput(payload='"\\udc80"', round_trip=AnsibleRuntimeError('Refusing to deserialize an invalid UTF8 string value.'), tags=()),

@ -41,12 +41,28 @@ _TestParameters(profile_name='inventory_legacy', value={'a': 1}, lazy=True): _Te
_TestParameters(profile_name='inventory_legacy', value={'a': 1}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"a": 1}', round_trip={'a': 1}, tags=()),
_TestParameters(profile_name='inventory_legacy', value=CustomMapping({'a': 1})): _TestOutput(payload='{"a": 1}', round_trip={'a': 1}, tags=()),
_TestParameters(profile_name='inventory_legacy', value=CustomMapping({'a': 1}), tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"a": 1}', round_trip={'a': 1}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={(1, 2): 'three'}): _TestOutput(payload='{"(1, 2)": "three"}', round_trip={'(1, 2)': 'three'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={(1, 2): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"(1, 2)": "three"}', round_trip={'(1, 2)': 'three'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={(1, 2): 'three'}, lazy=True): _TestOutput(payload='{"(1, 2)": "three"}', round_trip={'(1, 2)': 'three'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={(1, 2): 'three'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"(1, 2)": "three"}', round_trip={'(1, 2)': 'three'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={frozenset({1, 2}): 'three'}): _TestOutput(payload='{"frozenset({1, 2})": "three"}', round_trip={'frozenset({1, 2})': 'three'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"frozenset({1, 2})": "three"}', round_trip={'frozenset({1, 2})': 'three'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={frozenset({1, 2}): 'three'}, lazy=True): _TestOutput(payload='{"frozenset({1, 2})": "three"}', round_trip={'frozenset({1, 2})': 'three'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"frozenset({1, 2})": "three"}', round_trip={'frozenset({1, 2})': 'three'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={(1, 2): 'three'}): _TestOutput(payload=TypeError("Key of type 'tuple' is not JSON serializable by the 'inventory_legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='inventory_legacy', value={(1, 2): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'tuple' is not JSON serializable by the 'inventory_legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='inventory_legacy', value={(1, 2): 'three'}, lazy=True): _TestOutput(payload=TypeError("Key of type 'tuple' is not JSON serializable by the 'inventory_legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='inventory_legacy', value={(1, 2): 'three'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload=TypeError("Key of type 'tuple' is not JSON serializable by the 'inventory_legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='inventory_legacy', value={frozenset({1, 2}): 'three'}): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'inventory_legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='inventory_legacy', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'inventory_legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='inventory_legacy', value={frozenset({1, 2}): 'three'}, lazy=True): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'inventory_legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='inventory_legacy', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'inventory_legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='inventory_legacy', value={1: 'two'}): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={1: 'two'}, lazy=True): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={1: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={1.1: 'two'}): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={1.1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={1.1: 'two'}, lazy=True): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={1.1: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={True: 'two'}): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={True: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={True: 'two'}, lazy=True): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={True: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={None: 'two'}): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={None: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={None: 'two'}, lazy=True): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='inventory_legacy', value={None: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
}

@ -41,12 +41,28 @@ _TestParameters(profile_name='legacy', value={'a': 1}, lazy=True): _TestOutput(p
_TestParameters(profile_name='legacy', value={'a': 1}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"a": 1}', round_trip={'a': 1}, tags=()),
_TestParameters(profile_name='legacy', value=CustomMapping({'a': 1})): _TestOutput(payload='{"a": 1}', round_trip={'a': 1}, tags=()),
_TestParameters(profile_name='legacy', value=CustomMapping({'a': 1}), tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"a": 1}', round_trip={'a': 1}, tags=()),
_TestParameters(profile_name='legacy', value={(1, 2): 'three'}): _TestOutput(payload='{"(1, 2)": {"__ansible_unsafe": "three"}}', round_trip={'(1, 2)': 'three'}, tags=()),
_TestParameters(profile_name='legacy', value={(1, 2): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"(1, 2)": {"__ansible_unsafe": "three"}}', round_trip={'(1, 2)': 'three'}, tags=()),
_TestParameters(profile_name='legacy', value={(1, 2): 'three'}, lazy=True): _TestOutput(payload='{"(1, 2)": {"__ansible_unsafe": "three"}}', round_trip={'(1, 2)': 'three'}, tags=()),
_TestParameters(profile_name='legacy', value={(1, 2): 'three'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"(1, 2)": {"__ansible_unsafe": "three"}}', round_trip={'(1, 2)': 'three'}, tags=()),
_TestParameters(profile_name='legacy', value={frozenset({1, 2}): 'three'}): _TestOutput(payload='{"frozenset({1, 2})": {"__ansible_unsafe": "three"}}', round_trip={'frozenset({1, 2})': 'three'}, tags=()),
_TestParameters(profile_name='legacy', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"frozenset({1, 2})": {"__ansible_unsafe": "three"}}', round_trip={'frozenset({1, 2})': 'three'}, tags=()),
_TestParameters(profile_name='legacy', value={frozenset({1, 2}): 'three'}, lazy=True): _TestOutput(payload='{"frozenset({1, 2})": {"__ansible_unsafe": "three"}}', round_trip={'frozenset({1, 2})': 'three'}, tags=()),
_TestParameters(profile_name='legacy', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"frozenset({1, 2})": {"__ansible_unsafe": "three"}}', round_trip={'frozenset({1, 2})': 'three'}, tags=()),
_TestParameters(profile_name='legacy', value={(1, 2): 'three'}): _TestOutput(payload=TypeError("Key of type 'tuple' is not JSON serializable by the 'legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='legacy', value={(1, 2): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'tuple' is not JSON serializable by the 'legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='legacy', value={(1, 2): 'three'}, lazy=True): _TestOutput(payload=TypeError("Key of type 'tuple' is not JSON serializable by the 'legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='legacy', value={(1, 2): 'three'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload=TypeError("Key of type 'tuple' is not JSON serializable by the 'legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='legacy', value={frozenset({1, 2}): 'three'}): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='legacy', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='legacy', value={frozenset({1, 2}): 'three'}, lazy=True): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='legacy', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'legacy' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='legacy', value={1: 'two'}): _TestOutput(payload='{"1": {"__ansible_unsafe": "two"}}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"1": {"__ansible_unsafe": "two"}}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={1: 'two'}, lazy=True): _TestOutput(payload='{"1": {"__ansible_unsafe": "two"}}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={1: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"1": {"__ansible_unsafe": "two"}}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={1.1: 'two'}): _TestOutput(payload='{"1.1": {"__ansible_unsafe": "two"}}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={1.1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"1.1": {"__ansible_unsafe": "two"}}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={1.1: 'two'}, lazy=True): _TestOutput(payload='{"1.1": {"__ansible_unsafe": "two"}}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={1.1: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"1.1": {"__ansible_unsafe": "two"}}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={True: 'two'}): _TestOutput(payload='{"true": {"__ansible_unsafe": "two"}}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={True: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"true": {"__ansible_unsafe": "two"}}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={True: 'two'}, lazy=True): _TestOutput(payload='{"true": {"__ansible_unsafe": "two"}}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={True: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"true": {"__ansible_unsafe": "two"}}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={None: 'two'}): _TestOutput(payload='{"null": {"__ansible_unsafe": "two"}}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={None: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"null": {"__ansible_unsafe": "two"}}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={None: 'two'}, lazy=True): _TestOutput(payload='{"null": {"__ansible_unsafe": "two"}}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='legacy', value={None: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"null": {"__ansible_unsafe": "two"}}', round_trip={'null': 'two'}, tags=()),
}

@ -49,4 +49,20 @@ _TestParameters(profile_name='module_legacy_c2m', value={frozenset({1, 2}): 'thr
_TestParameters(profile_name='module_legacy_c2m', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'module_legacy_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={frozenset({1, 2}): 'three'}, lazy=True): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'module_legacy_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'module_legacy_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={1: 'two'}): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={1: 'two'}, lazy=True): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={1: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={1.1: 'two'}): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={1.1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={1.1: 'two'}, lazy=True): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={1.1: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={True: 'two'}): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={True: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={True: 'two'}, lazy=True): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={True: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={None: 'two'}): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={None: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={None: 'two'}, lazy=True): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_c2m', value={None: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
}

@ -62,4 +62,16 @@ _TestParameters(profile_name='module_legacy_m2c', value={(1, 2): 'three'}, tags=
_TestParameters(profile_name='module_legacy_m2c', value={frozenset({1, 2}): 'three'}): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'module_legacy_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_legacy_m2c', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'module_legacy_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_legacy_m2c', value={frozenset({1, 2}): 'three'}, tags=(TrustedAsTemplate(),)): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'module_legacy_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_legacy_m2c', value={1: 'two'}): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_m2c', value={1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"value": {"1": "two"}, "tags": [{"msg": "x", "__ansible_type": "Deprecated"}], "__ansible_type": "_AnsibleTaggedDict"}', round_trip={'1': 'two'}, tags=(Deprecated(msg='x'),)),
_TestParameters(profile_name='module_legacy_m2c', value={1: 'two'}, tags=(TrustedAsTemplate(),)): _TestOutput(payload=TypeError("Object of type 'TrustedAsTemplate' is not JSON serializable by the 'module_legacy_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_legacy_m2c', value={1.1: 'two'}): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_m2c', value={1.1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"value": {"1.1": "two"}, "tags": [{"msg": "x", "__ansible_type": "Deprecated"}], "__ansible_type": "_AnsibleTaggedDict"}', round_trip={'1.1': 'two'}, tags=(Deprecated(msg='x'),)),
_TestParameters(profile_name='module_legacy_m2c', value={1.1: 'two'}, tags=(TrustedAsTemplate(),)): _TestOutput(payload=TypeError("Object of type 'TrustedAsTemplate' is not JSON serializable by the 'module_legacy_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_legacy_m2c', value={True: 'two'}): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_m2c', value={True: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"value": {"true": "two"}, "tags": [{"msg": "x", "__ansible_type": "Deprecated"}], "__ansible_type": "_AnsibleTaggedDict"}', round_trip={'true': 'two'}, tags=(Deprecated(msg='x'),)),
_TestParameters(profile_name='module_legacy_m2c', value={True: 'two'}, tags=(TrustedAsTemplate(),)): _TestOutput(payload=TypeError("Object of type 'TrustedAsTemplate' is not JSON serializable by the 'module_legacy_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_legacy_m2c', value={None: 'two'}): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='module_legacy_m2c', value={None: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"value": {"null": "two"}, "tags": [{"msg": "x", "__ansible_type": "Deprecated"}], "__ansible_type": "_AnsibleTaggedDict"}', round_trip={'null': 'two'}, tags=(Deprecated(msg='x'),)),
_TestParameters(profile_name='module_legacy_m2c', value={None: 'two'}, tags=(TrustedAsTemplate(),)): _TestOutput(payload=TypeError("Object of type 'TrustedAsTemplate' is not JSON serializable by the 'module_legacy_m2c' profile."), round_trip=None, tags=()),
}

@ -49,4 +49,20 @@ _TestParameters(profile_name='module_modern_c2m', value={frozenset({1, 2}): 'thr
_TestParameters(profile_name='module_modern_c2m', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={frozenset({1, 2}): 'three'}, lazy=True): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={1: 'two'}): _TestOutput(payload=TypeError("Key of type 'int' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'int' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={1: 'two'}, lazy=True): _TestOutput(payload=TypeError("Key of type 'int' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={1: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload=TypeError("Key of type 'int' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={1.1: 'two'}): _TestOutput(payload=TypeError("Key of type 'float' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={1.1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'float' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={1.1: 'two'}, lazy=True): _TestOutput(payload=TypeError("Key of type 'float' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={1.1: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload=TypeError("Key of type 'float' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={True: 'two'}): _TestOutput(payload=TypeError("Key of type 'bool' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={True: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'bool' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={True: 'two'}, lazy=True): _TestOutput(payload=TypeError("Key of type 'bool' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={True: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload=TypeError("Key of type 'bool' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={None: 'two'}): _TestOutput(payload=TypeError("Key of type 'NoneType' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={None: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'NoneType' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={None: 'two'}, lazy=True): _TestOutput(payload=TypeError("Key of type 'NoneType' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_c2m', value={None: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload=TypeError("Key of type 'NoneType' is not JSON serializable by the 'module_modern_c2m' profile."), round_trip=None, tags=()),
}

@ -62,4 +62,16 @@ _TestParameters(profile_name='module_modern_m2c', value={(1, 2): 'three'}, tags=
_TestParameters(profile_name='module_modern_m2c', value={frozenset({1, 2}): 'three'}): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={frozenset({1, 2}): 'three'}, tags=(TrustedAsTemplate(),)): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={1: 'two'}): _TestOutput(payload=TypeError("Key of type 'int' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'int' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={1: 'two'}, tags=(TrustedAsTemplate(),)): _TestOutput(payload=TypeError("Key of type 'int' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={1.1: 'two'}): _TestOutput(payload=TypeError("Key of type 'float' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={1.1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'float' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={1.1: 'two'}, tags=(TrustedAsTemplate(),)): _TestOutput(payload=TypeError("Key of type 'float' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={True: 'two'}): _TestOutput(payload=TypeError("Key of type 'bool' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={True: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'bool' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={True: 'two'}, tags=(TrustedAsTemplate(),)): _TestOutput(payload=TypeError("Key of type 'bool' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={None: 'two'}): _TestOutput(payload=TypeError("Key of type 'NoneType' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={None: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'NoneType' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='module_modern_m2c', value={None: 'two'}, tags=(TrustedAsTemplate(),)): _TestOutput(payload=TypeError("Key of type 'NoneType' is not JSON serializable by the 'module_modern_m2c' profile."), round_trip=None, tags=()),
}

@ -49,4 +49,20 @@ _TestParameters(profile_name='tagless', value={frozenset({1, 2}): 'three'}): _Te
_TestParameters(profile_name='tagless', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'tagless' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='tagless', value={frozenset({1, 2}): 'three'}, lazy=True): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'tagless' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='tagless', value={frozenset({1, 2}): 'three'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload=TypeError("Key of type 'frozenset' is not JSON serializable by the 'tagless' profile."), round_trip=None, tags=()),
_TestParameters(profile_name='tagless', value={1: 'two'}): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={1: 'two'}, lazy=True): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={1: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"1": "two"}', round_trip={'1': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={1.1: 'two'}): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={1.1: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={1.1: 'two'}, lazy=True): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={1.1: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"1.1": "two"}', round_trip={'1.1': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={True: 'two'}): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={True: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={True: 'two'}, lazy=True): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={True: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"true": "two"}', round_trip={'true': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={None: 'two'}): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={None: 'two'}, tags=(Deprecated(msg='x'),)): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={None: 'two'}, lazy=True): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
_TestParameters(profile_name='tagless', value={None: 'two'}, tags=(Deprecated(msg='x'),), lazy=True): _TestOutput(payload='{"null": "two"}', round_trip={'null': 'two'}, tags=()),
}

@ -54,6 +54,10 @@ basic_values = (
CustomMapping(dict(a=1)),
{(1, 2): "three"}, # hashable non-scalar key
{frozenset((1, 2)): "three"}, # hashable non-scalar key
{1: "two"}, # int key
{1.1: "two"}, # float key
{True: "two"}, # bool key
{None: "two"}, # None key
)
# DTFIX5: we need tests for recursion, specifically things like custom sequences and mappings when:
@ -83,7 +87,7 @@ def test_cache_persistence_schema() -> None:
# DTFIX5: ensure all types/attrs included in _profiles._common_module_response_types are represented here, since they can appear in cached responses
expected_schema_id = 1
expected_schema_hash = "bf52e60cf1d25a3f8b6bfdf734781ee07cfe46e94189d2f538815c5000b617c6"
expected_schema_hash = "0bc4bec94abe6ec0f62fc9f45ea1099ea65b13f00a5e5de1699e0dbcf0de2b2c"
test_hash = hashlib.sha256()
test_hash.update(pathlib.Path(DataSet.PROFILE_DIR / _cache_persistence._Profile.profile_name).with_suffix('.txt').read_bytes())

Loading…
Cancel
Save