def test_list_of_lists(): x = [[1, 2], ["hello", "wookies"], [A(1), A(2)]] eq_(x, from_serializable_repr(to_serializable_repr(x)))
def test_dict_of_lists(): x = {"a": [1, 2, 3], "b": ["hello", "goodbye"], "1": [A(1), A(2)]} eq_(x, from_serializable_repr(to_serializable_repr(x)))
def test_tuple_to_serializable(): x = (1, 2.0, "wolves") eq_(x, from_serializable_repr(to_serializable_repr(x)))
def test_float(): eq_(1.4, from_serializable_repr(to_serializable_repr(1.4)))
def test_str(): eq_("waffles", from_serializable_repr(to_serializable_repr("waffles")))
def test_serialize_builtin_class(): int_reconstructed = from_serializable_repr(to_serializable_repr(int)) eq_(int, int_reconstructed)
def test_object_with_set_values(): x = B() eq_(x, from_serializable_repr(to_serializable_repr(x)))
def test_serialize_custom_class(): A_reconstructed = from_serializable_repr(to_serializable_repr(A)) eq_(A, A_reconstructed)
def test_namedtuple_to_json(): eq_(instance, from_serializable_repr(to_serializable_repr(instance)))
def test_serialize_custom_function(): fn_reconstructed = from_serializable_repr(to_serializable_repr(global_fn)) eq_(global_fn, fn_reconstructed)
def test_serialize_builtin_function(): fn_reconstructed = from_serializable_repr(to_serializable_repr(sum)) eq_(sum, fn_reconstructed)
def test_dict_with_tuple_keys(): x = {(1, 2): "hello"} eq_(x, from_serializable_repr(to_serializable_repr(x)))
def test_object_with_dict_values(): x = A(dict(snooze=5)) eq_(x, from_serializable_repr(to_serializable_repr(x)))
def test_bool(): eq_(False, from_serializable_repr(to_serializable_repr(False)))
def test_int(): eq_(1, from_serializable_repr(to_serializable_repr(1)))
def test_serialize_object_with_helpers(): instance_reconstructed = from_serializable_repr( to_serializable_repr(instance)) eq_(instance, instance_reconstructed)