示例#1
0
    def testIter(self):
        a = object()
        b = object()
        c = object()
        pol = policy_simple.Policy(identifier=None)
        pol.members = (a, b, c)

        self.assertEqual([a, b, c], list(pol))
示例#2
0
    def testAddMember(self):
        p = policy_simple.Policy('test')
        good = [
            policy_simple.Header(),
            policy_simple.Term('test'),
            policy_simple.BlankLine(),
            policy_simple.CommentLine('test'),
            policy_simple.Include('other_pol')
        ]
        bad = ('', 3, lambda x: x, policy_simple.Field('test'))

        for member in good:
            try:
                p.AddMember(member)
            except TypeError:
                self.fail('Policy should accept member "%s"' % member)
        self.assertEqual(good, p.members)

        for member in bad:
            self.assertRaises(TypeError, p.AddMember, member)
示例#3
0
 def testRejectsNonField(self):
     b = policy_simple.Block()
     for t in ('', 3, lambda x: x, policy_simple.Header(),
               policy_simple.Policy('test')):
         self.assertRaises(TypeError, b.AddField, t)