コード例 #1
0
def test_deep_json_datetime():
    data = {'test': [{'test2': datetime(2014, 2, 3, 18, 12, tzinfo=utc)}, ]}
    expect(json_datetime.dumps(data, indent=None)) == \
        '{"test": [{"test2": "2014-02-03T18:12:00Z"}]}'
コード例 #2
0
def test_roundtrip():
    data = {'test': datetime(2014, 2, 3, 18, 12, tzinfo=utc)}
    json = json_datetime.dumps(data, indent=None)
    expect(json_datetime.loads(json)) == data
コード例 #3
0
def test_json_no_datetime():
    class Test:
        pass
    data = {'test': Test()}
    with expect.raises(TypeError):
        json_datetime.dumps(data, indent=None)