Пример #1
0
def test_complex_exception_serializer_round_trip_json():
    exception = ComplexExceptionType("NotFound", "the object is missing")
    json_data = json_dumps({"exception": exception})
    actual_data = json_loads(json_data)
    assert "exception" in actual_data
    assert type(actual_data["exception"]) == Exception
    assert str(actual_data["exception"]) == str(exception)
Пример #2
0
def test_exception_serializer_round_trip_json():
    error_message = "unreachable host"
    json_data = json_dumps({"exception": ConnectionError(error_message)}, )
    actual_data = json_loads(json_data)
    assert "exception" in actual_data
    assert type(actual_data["exception"]) == ConnectionError
    assert str(actual_data["exception"]) == error_message
Пример #3
0
def test_serializers_generator_json():
    data = json_dumps((i for i in range(5)))
    assert json_loads(data) == [i for i in range(5)]
Пример #4
0
def test_serializers_round_trip_json_extra_types():
    expected_original_data = [ExtraType("baz", DATA), "qux"]
    data = json_dumps(expected_original_data, extra_encoders=extra_encoders)
    actual_data = json_loads(data, extra_decoders=extra_decoders)
    assert actual_data == expected_original_data
Пример #5
0
def test_serializers_round_trip_json():
    json_data = json_dumps(DATA)
    actual_data = json_loads(json_data)
    assert actual_data == DATA