

def testNextEvent(self):
    stream = StringIO('{"key1":"value", "key2":100, "key3":null,\n        "key4": true, "key5":false, "key6":-201.50E1, "key7":{"key8":"value2",\n        "key9":null}, "key10":["value3", 10101010101010101010101, null,\n        {} ] }')
    reader = pulljson.JSONPullParser(stream)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.START_OBJECT)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_NAME)
    self.assertEqual(event.value, 'key1')
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_VALUE)
    self.assertEqual(event.value, 'value')
    self.assertEqual(event.valueType, pulljson.STRING)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_NAME)
    self.assertEqual(event.value, 'key2')
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_VALUE)
    self.assertEqual(event.value, 100)
    self.assertEqual(event.valueType, pulljson.NUMBER)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_NAME)
    self.assertEqual(event.value, 'key3')
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_VALUE)
    self.assertIsNone(event.value)
    self.assertEqual(event.valueType, pulljson.NULL)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_NAME)
    self.assertEqual(event.value, 'key4')
    event = stream.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_VALUE)
    self.assertTrue(event.value)
    self.assertEqual(event.valueType, pulljson.BOOLEAN)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_NAME)
    self.assertEqual(event.value, 'key5')
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_VALUE)
    self.assertFalse(event.value)
    self.assertEqual(event.valueType, pulljson.BOOLEAN)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_NAME)
    self.assertEqual(event.value, 'key6')
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_VALUE)
    self.assertEqual(event.value, (- 2015))
    self.assertEqual(event.valueType, pulljson.NUMBER)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_NAME)
    self.assertEqual(event.value, 'key7')
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.START_OBJECT)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_NAME)
    self.assertEqual(event.value, 'key8')
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_VALUE)
    self.assertEqual(event.value, 'value2')
    self.assertEqual(event.valueType, pulljson.STRING)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_NAME)
    self.assertEqual(event.value, 'key9')
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_VALUE)
    self.assertIsNone(event.value)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.END_OBJECT)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.FIELD_NAME)
    self.assertEqual(event.value, 'key10')
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.START_ARRAY)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.ARRAY_VALUE)
    self.assertEqual(event.value, 'value3')
    self.assertEqual(event.valueType, pulljson.STRING)
    self.assertEqual(event.arrayIndex, 0)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.ARRAY_VALUE)
    self.assertEqual(event.value, 10101010101010101010101)
    self.assertEqual(event.valueType, pulljson.NUMBER)
    self.assertEqual(event.arrayIndex, 1)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.ARRAY_VALUE)
    self.assertIsNone(event.value)
    self.assertEqual(event.valueType, pulljson.NULL)
    self.assertEqual(event.arrayIndex, 2)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.START_OBJECT)
    self.assertEqual(event.arrayIndex, 3)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.END_OBJECT)
    self.assertEqual(event.arrayIndex, 3)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.END_ARRAY)
    event = reader.nextEvent()
    self.assertEqual(event.type, pulljson.END_OBJECT)
    event = reader.nextEvent()
    self.assertIsNone(event)

dataset/ETHPy150Open Teradata/PyTd/test/test_pulljson.py TestJSONPullParser.testNextEvent/VarMisuse@310/472 `reader`->`stream`