Beispiel #1
0
 def test_nonav(self):
     # Check that setting a key not given in the ctor fails
     d = DefaultDict(('a', 'b'))
     d['a'] = 1
     try:
         d['c'] = 2
         raise AssertionError('Setting a non existing key succeeded, '\
                              'should have failed.')
     except KeyError:
         pass
Beispiel #2
0
    def test_copy(self):
        from copy import copy
        a = DefaultDict(('a', 'b'))
        a['a'] = ['a']
        a['b'] = ['b']
        b = copy(a)
        b['b'] += 'c'

        assert not b['b'] == a['b']
        assert b['a'] == a['a']
        assert b['a'] is not a['a']
 def __init__(self):
     DefaultDict.__init__(self, _OPTIONS)
     for k in self.keys():
         self[k] = []
Beispiel #4
0
 def __init__(self):
     DefaultDict.__init__(self, _OPTIONS)
     for k in self.keys():
         self[k] = []
Beispiel #5
0
 def __init__(self):
     DefaultDict.__init__(self, self.__keys)
     for k in self.keys():
         self[k] = []
 def setUp(self):
     bld = DefaultDict.fromcallable(
             avkeys = build_config_factory_flags(),
             default = lambda: [])
     self.fa = BuildConfigFactory(bld)
Beispiel #7
0
    def test_fromcallable(self):
        a = DefaultDict.fromcallable(('1', '2'), lambda: [])
        assert not a['1'] is a['2']

        b = DefaultDict(('1', '2'), [])
        assert b['1'] is b['2']
Beispiel #8
0
    def test_fromcallable(self):
        a = DefaultDict.fromcallable(('1', '2'), lambda: [])
        assert not a['1'] is a['2']

        b = DefaultDict(('1', '2'), [])
        assert b['1'] is b['2']
Beispiel #9
0
 def test_defval(self):
     d = DefaultDict(('a', 'b'), default=1)
     a = d['a']
     b = d['b']
     assert a == b == 1
Beispiel #10
0
 def test_basic1(self):
     d = DefaultDict(('a', 'b'))
     a = d['a']
     b = d['b']
Beispiel #11
0
 def __init__(self):
     DefaultDict.__init__(self, self.__keys)
     for k in self.keys():
         self[k] = []