

def test_serialize_works_as_expected(self):
    item = ExceptionData()
    item.ver = 42
    item.handled_at = 'Test string'
    for value in [object()]:
        item.exceptions.append(value)
    item.severity_level = object()
    for (key, value) in {
        'key1': 'test value 1',
        'key2': 'test value 2',
    }.items():
        item.properties[key] = value
    for (key, value) in {
        'key1': 3.1415,
        'key2': 42.2,
    }.items():
        item.measurements[key] = value
    actual = json.dumps(item.write(), separators=(',', ':'), cls=TestJsonEncoder)
    expected = '{"ver":42,"handledAt":"Test string","exceptions":[{}],"severityLevel":{},"properties":{"key1":"test value 1","key2":"test value 2"},"measurements":{"key1":3.1415,"key2":42.2}}'
    self.assertEqual(expected, actual)

dataset/ETHPy150Open Microsoft/ApplicationInsights-Python/tests/applicationinsights_tests/channel_tests/contracts_tests/TestExceptionData.py TestExceptionData.test_serialize_works_as_expected/original