예제 #1
0
  def testRCopyNestedDict(self):
    d = {"a": {"b": {"c": 1}}}
    self.assertDictEqual(d, rCopy(d))

    def f(value, _keys):
      return value * 2
    expected = {"a": {"b": {"c": 2}}}
    self.assertDictEqual(expected, rCopy(d, f))
예제 #2
0
  def testRCopyFlatDict(self):
    d = {"a": 1, "b": 2, "c": 3}
    self.assertDictEqual(d, rCopy(d))

    def f(value, _keys):
      return value * 2
    expected = {"a": 2, "b": 4, "c": 6}
    self.assertDictEqual(expected, rCopy(d, f))
예제 #3
0
    def testRCopyNestedDict(self):
        d = {"a": {"b": {"c": 1}}}
        self.assertDictEqual(d, rCopy(d))

        def f(value, _keys):
            return value * 2

        expected = {"a": {"b": {"c": 2}}}
        self.assertDictEqual(expected, rCopy(d, f))
예제 #4
0
    def testRCopyFlatDict(self):
        d = {"a": 1, "b": 2, "c": 3}
        self.assertDictEqual(d, rCopy(d))

        def f(value, _keys):
            return value * 2

        expected = {"a": 2, "b": 4, "c": 6}
        self.assertDictEqual(expected, rCopy(d, f))
예제 #5
0
  def testRCopyComplexNestedDict(self):
    d = {"a": {"b": {"c": [1, 2, 3]}, "d": "Hello", "e": 17}}
    self.assertDictEqual(d, rCopy(d))

    def f(value, _keys):
      return value * 2
    expected = {"a": {"b": {"c": [1, 2, 3, 1, 2, 3]},
                      "d": "HelloHello", "e": 34}}
    self.assertDictEqual(expected, rCopy(d, f))
예제 #6
0
    def testRCopyComplexNestedDict(self):
        d = {"a": {"b": {"c": [1, 2, 3]}, "d": "Hello", "e": 17}}
        self.assertDictEqual(d, rCopy(d))

        def f(value, _keys):
            return value * 2

        expected = {
            "a": {
                "b": {
                    "c": [1, 2, 3, 1, 2, 3]
                },
                "d": "HelloHello",
                "e": 34
            }
        }
        self.assertDictEqual(expected, rCopy(d, f))
예제 #7
0
 def testRCopyEmpty(self):
     d = {}
     self.assertDictEqual(d, rCopy(d))
     self.assertDictEqual(d, rCopy(d, lambda x: 2 * x))
예제 #8
0
 def testRCopyEmpty(self):
   d = {}
   self.assertDictEqual(d, rCopy(d))
   self.assertDictEqual(d, rCopy(d, lambda x: 2* x))