def testRCopyFlatDict(self):
    d = {"a": 1, "b": 2, "c": 3}
    self.assertDictEqual(d, dictutils.rCopy(d))

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

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

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

    def f(value, _keys):
      return value * 2
    expected = {"a": 2, "b": 4, "c": 6}
    self.assertDictEqual(expected, dictutils.rCopy(d, f))
  def testRCopyComplexNestedDict(self):
    d = {"a": {"b": {"c": [1, 2, 3]}, "d": "Hello", "e": 17}}
    self.assertDictEqual(d, dictutils.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, dictutils.rCopy(d, f))
示例#6
0
  def testRCopyComplexNestedDict(self):
    d = {"a": {"b": {"c": [1, 2, 3]}, "d": "Hello", "e": 17}}
    self.assertDictEqual(d, dictutils.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, dictutils.rCopy(d, f))
 def testRCopyEmpty(self):
   d = {}
   self.assertDictEqual(d, dictutils.rCopy(d))
   self.assertDictEqual(d, dictutils.rCopy(d, lambda x: 2* x))
示例#8
0
 def testRCopyEmpty(self):
   d = {}
   self.assertDictEqual(d, dictutils.rCopy(d))
   self.assertDictEqual(d, dictutils.rCopy(d, lambda x: 2* x))