Ejemplo n.º 1
0
    def test_immutable(self):
        d = frozendict()

        with self.assertRaises(Exception):
            d['hello'] = 'world'

        d = frozendict({'hello': 'world'})

        with self.assertRaises(Exception):
            d['hello'] = 'world'
Ejemplo n.º 2
0
    def test_immutable(self):
        d = frozendict()

        with self.assertRaises(Exception):
            d['hello'] = 'world'

        d = frozendict({'hello':'world'})

        with self.assertRaises(Exception):
            d['hello'] = 'world'
Ejemplo n.º 3
0
 def freeze(self):
     if self.frozen:
         return
     if isinstance(self.value, Reference):
         raise ASTError('setting %s.%s is a reference with no resolved '
             'value' % (self.instance, self.attribute), self)
     if self.attribute in C_KEYWORDS:
         raise ASTError('setting name \'%s\' clashes with a C keyword' %
             self.attribute, self)
     if isinstance(self.value, list):
         self.value = tuple(self.value)
     elif isinstance(self.value, dict):
         self.value = frozendict(self.value)
     super(Setting, self).freeze()
Ejemplo n.º 4
0
 def freeze(self):
     if self.frozen:
         return
     if isinstance(self.value, Reference):
         raise ASTError('setting %s.%s is a reference with no resolved '
             'value' % (self.instance, self.attribute), self)
     if self.attribute in C_KEYWORDS:
         raise ASTError('setting name \'%s\' clashes with a C keyword' %
             self.attribute, self)
     if isinstance(self.value, list):
         self.value = tuple(self.value)
     elif isinstance(self.value, dict):
         self.value = frozendict(self.value)
     super(Setting, self).freeze()
Ejemplo n.º 5
0
    def test_construction(self):
        d = frozendict()
        self.assertIsNone(d.get('hello'))

        d = frozendict({'hello': 'world'})
        self.assertEqual(d['hello'], 'world')
Ejemplo n.º 6
0
    def test_construction(self):
        d = frozendict()
        self.assertIsNone(d.get('hello'))

        d = frozendict({'hello':'world'})
        self.assertEqual(d['hello'], 'world')