示例#1
0
def test_attributes():
    for x in [datetime.date.today(),
              datetime.time(),
              datetime.datetime.utcnow(),
              datetime.timedelta(),
              datetime.tzinfo()]:
        raises(AttributeError, 'x.abc = 1')
示例#2
0
def test_unpickle():
    e = raises(TypeError, datetime.date, '123')
    assert e.value.args[0] == 'an integer is required'
    e = raises(TypeError, datetime.time, '123')
    assert e.value.args[0] == 'an integer is required'
    e = raises(TypeError, datetime.datetime, '123')
    assert e.value.args[0] == 'an integer is required'

    datetime.time('\x01' * 6, None)
    with raises(TypeError) as e:
        datetime.time('\x01' * 6, 123)
    assert str(e.value) == "bad tzinfo state arg"

    datetime.datetime('\x01' * 10, None)
    with raises(TypeError) as e:
        datetime.datetime('\x01' * 10, 123)
    assert str(e.value) == "bad tzinfo state arg"