def test_to_dict(self): doc = BioDesDoc() doc.from_url(os.path.join(this_dir, 'bio.xml')) d = doc.to_dict() assert 'geboortedatum' in d, d assert doc.get_value('geboortedatum') self.assertEqual(type(doc.get_value('geboortedatum')), type(u''))
def test_round_trip(k, o, **dict): """test a 'round trip': create a biodes doc with 'from_args', and then parse the file using 'to_dict' k = the key o = the expected oubput dict : the data used to create the biodes document """ if not dict: dict = {k:o} el = self.create_element(**dict) doc = BioDesDoc().from_element(el) dct = doc.to_dict() assert dct.has_key(k), doc.to_string() assert dct[k] == o, '%s shoudl be "%s", not "%s"\n%s' % (k, o, dct[k], doc.to_string())