Beispiel #1
0
    def test_control_characters(self):
        self.assertTrue('\n' in jsonfsm.loads(self.multiline_json_string))

        self.assertEquals(jsonfsm.loads('"\u2022"'), u"•")

        self.assertRaises(jsonfsm.JSONParseError,
                          jsonfsm.loads,
                          self.json_string[:-1] + r'\k"')
Beispiel #2
0
 def test_valid_arrays(self):
     for json, expected in self.valid:
         self.assertEquals(jsonfsm.loads(json), expected)
Beispiel #3
0
 def test_valid_numbers(self):
     for n in self.numbers:
         self.assertEquals(jsonfsm.loads(n), float(n))
Beispiel #4
0
    def test_character_encoding(self):
        l1_encoded = self.another_json_string.encode("latin1")
        res = jsonfsm.loads(l1_encoded, "latin1")

        self.assertEquals(res, jsonfsm.loads(self.another_json_string))
        self.assertEquals(res, self.another_python_string)
Beispiel #5
0
    def test_decode(self):
        res = jsonfsm.loads(self.json_string)

        self.assertTrue(isinstance(res, unicode))
        self.assertEquals(res, self.python_string)
Beispiel #6
0
 def test_conformance(self):
     for json in self.json_files:
         with open(json) as infile:
             data = infile.read()
             self.assertEquals(jsonfsm.loads(data), self.json.loads(data))