Ejemplo n.º 1
0
    def test_order(self):
        one = OrderedDeclarationMock(1)
        two = OrderedDeclarationMock(2)
        ten = OrderedDeclarationMock(10)
        d = OrderedDeclarationDict(one=one, two=two, ten=ten)

        self.assertEqual(['one', 'two', 'ten'], list(d))
        self.assertEqual([('one', one), ('two', two), ('ten', ten)],
                         d.items())
        self.assertEqual([('one', one), ('two', two), ('ten', ten)],
                         list(d.iteritems()))
Ejemplo n.º 2
0
    def test_basics(self):
        one = OrderedDeclarationMock(1)
        two = OrderedDeclarationMock(2)
        three = OrderedDeclarationMock(3)
        d = OrderedDeclarationDict(one=one, two=two, three=three)
        self.assertEqual(one, d['one'])
        self.assertEqual(two, d['two'])
        self.assertEqual(three, d['three'])

        self.assertTrue('one' in d)
        self.assertTrue('two' in d)
        self.assertTrue('three' in d)

        self.assertEqual(one, d.pop('one'))
        self.assertFalse('one' in d)

        d['one'] = one
        self.assertTrue('one' in d)
        self.assertEqual(one, d['one'])

        self.assertEqual(set(['one', 'two', 'three']),
                         set(d))