MCPcopy Create free account
hub / github.com/EntilZha/PyFunctional / test_cache

Method test_cache

functional/test/test_functional.py:888–901  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

886 )
887
888 def test_cache(self):
889 if self.seq is pseq:
890 raise self.skipTest("pseq doesn't support functions with side-effects")
891 calls = []
892 func = lambda x: calls.append(x)
893 result = self.seq(1, 2, 3).map(func).cache().map(lambda x: x).to_list()
894 self.assertEqual(len(calls), 3)
895 self.assertEqual(result, [None, None, None])
896 result = self.seq(1, 2, 3).map(lambda x: x).cache()
897 self.assertEqual(
898 repr(result._lineage), "Lineage: sequence -> map(<lambda>) -> cache"
899 )
900 result = self.seq(1, 2, 3).map(lambda x: x).cache(delete_lineage=True)
901 self.assertEqual(repr(result._lineage), "Lineage: sequence")
902
903 def test_tabulate(self):
904 sequence = seq([[1, 2, 3], [4, 5, 6]])

Callers

nothing calls this directly

Calls 3

to_listMethod · 0.80
mapMethod · 0.80
cacheMethod · 0.80

Tested by

no test coverage detected