예제 #1
0
 def inflate(self, deflated_space: Dict) -> Dict:
     return inflate({
         **deflated_space,
         **self._fixed
     },
                    sep=self._sep,
                    leave_tuples=True)
def test_tuple_keys():
    my_dict = {
        (1,"d"):6,
        (56, 56,"d"):6,
        (1,"d", True):6
    }
    assert my_dict == inflate(deflate(my_dict))
예제 #3
0
def test_inflate_deflate():
    dictionaries = [test_dict] + [
        random_int_dict(4, 4) for i in range(100)
    ] + [random_float_dict(4, 4)
         for i in range(100)] + [random_string_dict(4, 4) for i in range(100)]
    for d in dictionaries:
        assert d == inflate(deflate(d))
        assert d == inflate(deflate(d, leave_tuples=True), leave_tuples=True)

    string_dictionaries = [{"test": {"test": {"test": [1, 2, 3, 4]}}}]
    for d in string_dictionaries:
        assert d == inflate(deflate(d, type_encode_key=False),
                            type_decode_key=False)
        assert d == inflate(deflate(d,
                                    leave_tuples=True,
                                    type_encode_key=False),
                            leave_tuples=True,
                            type_decode_key=False)
예제 #4
0
def test_list_encoding():
    my_dict = {
        "root": [
            0, 2, {
                "weigh":67
            }
        ]
    }
    assert match(my_dict, inflate(deflate(my_dict)))
예제 #5
0
def test_non_list_encoding():
    my_dict = {
        "root": {
            0: 0,
            1: 2,
            2: {
                "weigh":67
            }
        }
    }
    assert match(my_dict, inflate(deflate(my_dict)))