import pytest @pytest.mark.parametrize( 'value,expected', [ (None, None), ([1, 2, 3], '[1, 2, 3]'), ({'a': 1, 'b': 2}, '{"a": 1, "b": 2}'), ] ) def test_json_encoder_bind(value, expected): from ordr.models.meta import JsonEncoder encoder = JsonEncoder() assert encoder.process_bind_param(value, None) == expected @pytest.mark.parametrize( 'value,expected', [ (None, None), ('[1, 2, 3]', [1, 2, 3]), ('{"a": 1, "b":2}', {'a': 1, 'b': 2}), ] ) def test_json_encoder_result(value, expected): from ordr.models.meta import JsonEncoder encoder = JsonEncoder() assert encoder.process_result_value(value, None) == expected @pytest.mark.parametrize('value', [None, [1, 2, 3], {'a': 1, 'b': 2}]) def test_json_encoder_bind_and_result(value): from ordr.models.meta import JsonEncoder encoder = JsonEncoder() result = encoder.process_bind_param(value, None) assert encoder.process_result_value(result, None) == value