def test_max_size(clean): """ testing behavior when reatching maximum size """ TransparentPath.caching_max_memory = 0.000070 TransparentPath.caching = "ram" TransparentPath("tests/data/chat.txt", enable_caching=True, fs="local").read() path = TransparentPath("tests/data/groschat.txt", enable_caching=True, fs="local") path.read() ret = list(TransparentPath.cached_data_dict.keys()) retdata = list(TransparentPath.cached_data_dict.values()) assert len(ret) == 1 assert ret[0] == path.__hash__() assert retdata[0]["data"] == "grostest"
def test_caching_ram(clean, suffix, kwargs): if reqs_ok: import pandas as pd data = pd.DataFrame(columns=["foo", "bar"], index=["a", "b"], data=[[1, 2], [3, 4]]) TransparentPath.caching = "ram" path = TransparentPath(f"tests/data/chien{suffix}", enable_caching=True, fs="local") path.read(**kwargs) assert all( TransparentPath.cached_data_dict[path.__hash__()]["data"] == data) assert all( TransparentPath(f"tests/data/chien{suffix}", enable_caching=True, fs="local").read() == data)