Ejemplo n.º 1
0
    def test_dataclass_with_list_caches_class(self):
        json_dataclass_with_list = '{"xs": [1]}'
        _ = DataClassWithList.from_json(json_dataclass_with_list)

        # type hints for class cached
        assert _get_type_hints_cache._Cache__currsize == 1
        # supported generic called for List[int] and int itself
        assert _is_supported_generic_cache._Cache__currsize == 2
        # for the dataclass
        assert _user_overrides_cache._Cache__currsize == 1

        # force cache hits
        _ = DataClassWithList.from_json(json_dataclass_with_list)

        assert _get_type_hints_cache._Cache__currsize == 1
        assert _is_supported_generic_cache._Cache__currsize == 2
        assert _user_overrides_cache._Cache__currsize == 1
Ejemplo n.º 2
0
 def test_list(self):
     assert (
         DataClassWithList.from_json('{"xs": [1]}') == DataClassWithList(
             [1]))