Пример #1
0
 def test_popitem(self):
     dict1 = xmlstring2dict(xmlstr,
                            use_ord_dict=False,
                            always_singular_list=[])
     ordered_dict = OrderedDict(dict1)
     self.assertEqual("(u'temperature', {u'C': u'40', u'F': u'100'})",
                      ordered_dict.popitem().__repr__())
Пример #2
0
 def test_items(self):
     dict1 = xmlstring2dict(xmlstr,
                            use_ord_dict=False,
                            always_singular_list=[])
     ordered_dict = OrderedDict(dict1)
     self.assertEqual(ordered_dict_items_repr,
                      ordered_dict.items().__repr__())
Пример #3
0
 def test_keys(self):
     dict1 = xmlstring2dict(xmlstr,
                            use_ord_dict=False,
                            always_singular_list=[])
     ordered_dict = OrderedDict(dict1)
     self.assertEqual("[u'date', u'files', u'params', u'temperature']",
                      ordered_dict.keys().__repr__())
Пример #4
0
 def test_clear(self):
     dict1 = xmlstring2dict(xmlstr,
                            use_ord_dict=False,
                            always_singular_list=[])
     ordered_dict = OrderedDict(dict1)
     ordered_dict.clear()
     self.assertEqual('{}', ordered_dict.__repr__())
Пример #5
0
 def test_copy(self):
     dict1 = xmlstring2dict(xmlstr,
                            use_ord_dict=False,
                            always_singular_list=[])
     ordered_dict = OrderedDict(dict1)
     od2 = ordered_dict.copy()
     self.assertEqual(od2.__repr__(), ordered_dict.__repr__())
Пример #6
0
 def test___setitem__(self):
     dict1 = xmlstring2dict(xmlstr,
                            use_ord_dict=False,
                            always_singular_list=[])
     ordered_dict = OrderedDict(dict1)
     ordered_dict.__setitem__("foo", "bar")
     self.assertTrue('foo' in ordered_dict)
Пример #7
0
 def test_update(self):
     dict1 = xmlstring2dict(xmlstr,
                            use_ord_dict=False,
                            always_singular_list=[])
     ordered_dict = OrderedDict(dict1)
     upd = {"foo": "bar"}
     ordered_dict.update(upd)
     self.assertTrue("foo" in ordered_dict)
Пример #8
0
 def test___delitem__(self):
     dict1 = xmlstring2dict(xmlstr,
                            use_ord_dict=False,
                            always_singular_list=[])
     ordered_dict = OrderedDict(dict1)
     od2 = ordered_dict.copy()
     ordered_dict.__delitem__('temperature')
     self.assertTrue('temperature' in od2)
     self.assertFalse('temperature' in ordered_dict)
Пример #9
0
 def test_setdefault(self):
     dict1 = xmlstring2dict(xmlstr,
                            use_ord_dict=False,
                            always_singular_list=[])
     ordered_dict = OrderedDict(dict1)
     failobj = 'not here'
     ordered_dict.setdefault('Dave', failobj)
     self.assertEqual(ordered_dict.get('Dave'), failobj)
     ordered_dict['Dave'] = 'here'
     self.assertNotEqual(ordered_dict.get('Dave'), failobj)
     self.assertEqual(ordered_dict.get('Dave'), 'here')
Пример #10
0
 def test___init__(self):
     dict1 = xmlstring2dict(xmlstr,
                            use_ord_dict=False,
                            always_singular_list=[])
     ordered_dict = OrderedDict(dict1)
     self.assertNotEqual(ordered_dict, None)