コード例 #1
0
 def test_OrdDict_001_09(self):
     """Test 'self.clear()' of the OrdDict."""
     my_test_dict5 = OrdDict()
     my_test_dict5['A'] = '4711'
     my_test_dict5['B'] = '4712'
     my_test_dict5['C'] = '4713'
     my_test_dict5['D'] = '4714'
     my_test_dict5.clear()
     self.assertTrue('A' not in my_test_dict5)
     self.assertTrue(len(my_test_dict5) == 0)
コード例 #2
0
 def test_OrdDict_001_04(self):
     """Test delattr, delitem of the OrdDict."""
     my_test_dict4 = OrdDict()
     my_test_dict4['A'] = '4711'
     my_test_dict4['B'] = '4712'
     my_test_dict4['C'] = '4713'
     my_test_dict4['D'] = '4714'
     del my_test_dict4['C']
     del my_test_dict4.D
     self.assertFalse('C' in my_test_dict4.keys())
     self.assertFalse('D' in my_test_dict4.keys())
コード例 #3
0
    def test_OrdDict_001_00(self):
        """Test equality and order of OrdDict."""
        my_test_dict1 = OrdDict()
        my_test_dict1['field_a'] = '4711'
        my_test_dict1['field_b'] = '1234.4567'
        my_test_dict1['field_c'] = '1'
        my_test_dict1['field_d'] = 'Thank you for the fish'
        self.assertEqual(self.my_ord_dict, my_test_dict1)

        my_test_dict2 = OrdDict()
        my_test_dict2['field_a'] = '1234.4567'
        my_test_dict2['field_b'] = '4711'
        my_test_dict2['field_c'] = '1'
        my_test_dict2['field_d'] = 'Thank you for the fish'
        self.assertNotEqual(self.my_ord_dict, my_test_dict2)
コード例 #4
0
 def test_OrdDict_001_03(self):
     """Test setattr, getattr, delattr of local variables."""
     my_test_dict3 = OrdDict()
     my_test_dict3._localvars.append('dummy')
     my_test_dict3['field_a'] = '1234.4567'
     my_test_dict3['field_b'] = '4711'
     my_test_dict3['field_c'] = '1'
     my_test_dict3['field_d'] = 'Thank you for the fish'
     self.assertTrue('dummy' in my_test_dict3._localvars)
     my_test_dict3.dummy = 'd1'
     self.assertFalse('dummy' in my_test_dict3.keys())
     dummy_value = my_test_dict3.dummy
     self.assertTrue(dummy_value == 'd1')
     my_test_dict3.dummy = 'd2'
     dummy_value = my_test_dict3.dummy
     #print(my_test_dict3.__dict__)
     self.assertTrue(dummy_value == 'd2')
     self.assertTrue(dummy_value == my_test_dict3.__getattr__('dummy'))
     self.assertTrue('dummy' in my_test_dict3.__dict__.keys())
     del my_test_dict3.dummy
     self.assertFalse('dummy' in my_test_dict3.__dict__.keys())
     self.assertFalse('dummy' in my_test_dict3._field_order)
コード例 #5
0
 def __init__(self, xml):
     OrdDict.__init__(self)
     if xml is None: return
     for cert in xml.getchildren():
         self[cert.attrib['locale']] = cert.attrib['name']
コード例 #6
0
 def __init__(self, xml):
     list.__init__(self)
     if xml is None: return
     for item in xml.getchildren():
         self.append(OrdDict(item.attrib.items()))
コード例 #7
0
 def __init__(self, xml):
     OrdDict.__init__(self)
     if xml is None: return
     for cert in list(xml):
         self[cert.attrib['locale']] = cert.attrib['name']
コード例 #8
0
ファイル: system.py プロジェクト: Olti/mythtv
 def __init__(self, xml):
     OrdDict.__init__(self)
     if xml is None: return
     for cert in xml.getchildren():
         self[cert.attrib['locale']] = cert.attrib['name']
コード例 #9
0
 def setUpClass(cls):
     cls.field_values = ['4711', '1234.4567', '1', 'Thank you for the fish']
     cls.field_keys = ['field_a', 'field_b', 'field_c', 'field_d']
     cls.my_ord_dict = OrdDict(zip(cls.field_keys, cls.field_values))