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

Method test_dict

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

Source from the content-addressed store, hash-verified

769 self.assertEqual(result[4], 100)
770
771 def test_dict(self):
772 l = [(1, 2), (2, 10), (7, 2)]
773 d = {1: 2, 2: 10, 7: 2}
774 result = self.seq(l).dict()
775 self.assertDictEqual(result, d)
776 self.assertTrue(isinstance(result, dict))
777 result = self.seq(l).dict(default=lambda: 100)
778 self.assertTrue(1 in result)
779 self.assertFalse(3 in result)
780 self.assertEqual(result[4], 100)
781 result = self.seq(l).dict(default=100)
782 self.assertTrue(1 in result)
783 self.assertFalse(3 in result)
784 self.assertEqual(result[4], 100)
785
786 def test_reduce_by_key(self):
787 l = [("a", 1), ("a", 2), ("a", 3), ("b", -1), ("b", 1), ("c", 10), ("c", 5)]

Callers

nothing calls this directly

Calls 1

dictMethod · 0.80

Tested by

no test coverage detected