Пример #1
0
    def test_all_public_attributes_names_are_reserved(self):
        public_attributes = set([n for n in dir(Property('test')) if not n.startswith('_')])

        unreserved = public_attributes - set(Property._reserved())

        self.assertTrue(len(unreserved) == 0,
                        '''all public attributes of Configuraion objects must be reserved.
                        unreserved: %s''' % (unreserved,))
Пример #2
0
    def test_nonreserved_attributes_can_be_set(self):
        p = Property('test', 1)
        self.assertFalse('scattermonkey' in Property._reserved(), "precondition")

        p.scattermonkey = 9
Пример #3
0
 def test_there_are_reserved_words(self):
     self.assertTrue(len(Property._reserved()) > 0)
Пример #4
0
    def test_reserved_attributes_cannot_be_set(self):
        p = Property('test', value=1)
        self.assertTrue('int' in Property._reserved(), "precondition")

        with self.assertRaises(AttributeError):
            p.int = 9
Пример #5
0
 def test_name_must_not_be_reserved(self):
     self.assertTrue('int' in Property._reserved(), "precondition")
     self.assertRaises(ConfigError, Property, name='int')