Example #1
0
    def test_with_values(self):
        """Provide values for ``somedict`` and ``mapping``.

        Ensure that keys are updated correctly. Also, the output should be a
        copy of the input, so make sure that the input value does not change.

        """
        somedict = {1: 2, 3: 4}

        self.assertEqual(
            {0: 2, 3: 4},
            factory._copy_and_update_keys(somedict, ((1, 0),))
        )
        self.assertEqual({1: 2, 3: 4}, somedict)

        self.assertEqual(
            {0: 2, 'foo': 4},
            factory._copy_and_update_keys(somedict, ((1, 0), (3, 'foo')))
        )
        self.assertEqual({1: 2, 3: 4}, somedict)
Example #2
0
 def test_empty_mapping(self):
     """Provide an empty value for ``mapping``."""
     self.assertEqual(
         {1: 2, 3: 4},
         factory._copy_and_update_keys({1: 2, 3: 4}, tuple())
     )
Example #3
0
 def test_empty_somedict(self):
     """Provide an empty value for ``somedict``."""
     self.assertEqual(
         {},
         factory._copy_and_update_keys({}, (('foo', 'bar'), (1, 2)))
     )
Example #4
0
 def test_empty_args(self):
     """Provide empty values for ``somedict`` and ``mapping``."""
     self.assertEqual(
         {},
         factory._copy_and_update_keys({}, tuple())
     )