Example #1
0
    def test_empty(self):
        d = {}
        partial._merge({}, d)
        self.assertFalse(d)

        d = {'a': {}}
        partial._merge({}, d)
        self.assertEqual(d, {
            'a': {},
        })
Example #2
0
    def test_recursive(self):
        d = {}
        partial._merge({'a': {'b': {}}}, d)
        self.assertEqual(d, {
            'a': {
                'b': {},
            },
        })

        d = {'a': {'c': {}}}
        partial._merge({'a': {'b': {}}}, d)
        self.assertEqual(d, {
            'a': {
                'b': {},
                'c': {},
            },
        })

        d = {'a': {'d': {'e': {}}}}
        partial._merge({'a': {'b': {'c': {}}}}, d)
        self.assertEqual(d, {
            'a': {
                'b': {
                    'c': {},
                },
                'd': {
                    'e': {},
                }
            },
        })

        d = {'a': {'b': {'c': {'f': {}}, 'g': {}}}}
        partial._merge({'a': {'b': {'c': {'d': {}, 'e': {}}}}}, d)
        self.assertEqual(d, {
            'a': {
                'b': {
                    'c': {
                        'd': {},
                        'e': {},
                        'f': {},
                    },
                    'g': {},
                },
            },
        })
Example #3
0
    def test_simple(self):
        d = {}
        partial._merge({'a': {}}, d)
        self.assertEqual(d, {
            'a': {},
        })

        d = {'a': {}}
        partial._merge({'a': {}}, d)
        self.assertEqual(d, {
            'a': {},
        })

        d = {'b': {}}
        partial._merge({'a': {}}, d)
        self.assertEqual(d, {
            'a': {},
            'b': {},
        })