예제 #1
0
def test_convert_unknown():
    val = ValidationError('Some Error')
    with pytest.raises(TypeError) as e:
        convert(val)
    assert 'ValidationError can not be converted to JSON.' == str(e.value)
예제 #2
0
def test_convert_date():
    val = date(2017, 1, 12)
    assert convert(val) == '2017-01-12'
예제 #3
0
def test_convert_datetime():
    val = datetime(2017, 1, 12, 13, 6, 11)
    assert convert(val) == '2017-01-12T13:06:11'
예제 #4
0
def test_convert_decimal():
    val = Decimal('1.1')
    assert convert(val) == 1.1