Esempio n. 1
0
 def test_deserialization(self):
     for frm, to in expected_mappings.items():
         self.assertEquals(rison.loads(frm), to)
Esempio n. 2
0
 def read_plist(self, fname):
     self.pbxproj = loads(open(fname).read())
Esempio n. 3
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), )
Esempio n. 4
0
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
Esempio n. 5
0
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
Esempio n. 6
0
 def test_deserialization(self):
     for frm, to in expected_mappings.items():
         self.assertEquals(rison.loads(frm), to)
Esempio n. 7
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),)