コード例 #1
0
ファイル: test_ordered_dict.py プロジェクト: shishakt/cylc
    def test_prepend(self):
        d = OrderedDictWithDefaults()
        d['key'] = 'Birds'
        d.prepend('year', 1980)
        d.prepend('key', 2000)

        iterator = d.iterkeys()

        self.assertEqual('key', iterator.next())
        self.assertEqual('year', iterator.next())

        d = OrderedDictWithDefaults()
        d['key'] = 'Birds'
        d.prepend('year', 1980)

        iterator = d.iterkeys()

        self.assertEqual('year', iterator.next())
        self.assertEqual('key', iterator.next())
コード例 #2
0
 def test_iterkeys(self):
     d = OrderedDictWithDefaults()
     self.assertEqual([], d.items())
     d['key'] = 'Birds'
     d['len'] = '89'
     d.defaults_ = {'surname': 'Wyndham'}
     count = 0
     for k in d.iterkeys():
         self.assertTrue(k in ['key', 'len', 'surname'])
         count += 1
     self.assertEqual(3, count)