File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,3 +121,32 @@ def test_xml_string(self):
121121 self .assertEqual (str (xml_doc .date ), date )
122122 self .assertEqual (len (xml_doc .sections ), 1 )
123123 self .assertEqual (xml_doc .sections [0 ].name , sec_name )
124+
125+ def test_json_string (self ):
126+ author = "HPL"
127+ date = "1890-08-20"
128+ sec_name = "section name"
129+ sec_type = "section type"
130+ doc = """
131+ {
132+ "odml-version": "1.1",
133+ "Document": {
134+ "author": "%s",
135+ "date": "%s",
136+ "sections": [{
137+ "name": "%s",
138+ "type": "%s"
139+ }]
140+ }
141+ }
142+ """ % (author , date , sec_name , sec_type )
143+
144+ json_doc = self .json_reader .from_string (doc )
145+
146+ self .assertEqual (json_doc .author , author )
147+ self .assertEqual (str (json_doc .date ), date )
148+ self .assertEqual (len (json_doc .sections ), 1 )
149+ self .assertEqual (json_doc .sections [0 ].name , sec_name )
150+
151+ # Test empty return on broken json document
152+ self .assertIsNone (self .json_reader .from_string ("{" ))
You can’t perform that action at this time.
0 commit comments