def test_deserialization(self): for frm, to in expected_mappings.items(): self.assertEquals(rison.loads(frm), to)
def read_plist(self, fname): self.pbxproj = loads(open(fname).read())
}, "(id:!n,type:/common/document)": { 'type': '/common/document', 'id': None }, "!()": [], "!(!t,!f,!n,'')": [True, False, None, ''], "'-h'": "-h", "a-z": "a-z", "'wow!!'": "wow!", "domain.com": "domain.com", "'*****@*****.**'": "*****@*****.**", "'US $10'": "US $10", "'can!'t'": "can't", } class TestRisonParser(unittest.TestCase): def test_deserialization(self): for frm, to in expected_mappings.items(): self.assertEquals(rison.loads(frm), to) if __name__ == '__main__': for s in expected_mappings.keys(): print print '*' * 70 print print s print '%r' % (rison.loads(s), )
from parser import loads if __name__ == '__main__': # a simple test # example below is from http://json.org/example example = '''{ "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML"] }, "GlossSee": "markup" } } } } ''' import json assert cmp(loads(example), json.loads(example)) == 0
"G.": "G.", "a": "a", "'0a'": "0a", "'abc def'": "abc def", "()": {}, "(a:0)": {'a': 0}, "(id:!n,type:/common/document)": {'type': '/common/document', 'id': None}, "!()": [], "!(!t,!f,!n,'')": [True, False, None, ''], "'-h'": "-h", "a-z": "a-z", "'wow!!'": "wow!", "domain.com": "domain.com", "'*****@*****.**'": "*****@*****.**", "'US $10'": "US $10", "'can!'t'": "can't", } class TestRisonParser(unittest.TestCase): def test_deserialization(self): for frm, to in expected_mappings.items(): self.assertEquals(rison.loads(frm), to) if __name__ == '__main__': for s in expected_mappings.keys(): print print '*'*70 print print s print '%r' % (rison.loads(s),)