Esempio n. 1
0
def test_dt_as_timezone_conversions():
    dt = datetime.datetime(2014, 5, 23, 16, 39, 32, 125099, tzinfo=pytz.UTC)
    eq_(dt.strftime('%Y-%m-%d %H:%M:%S %Z%z'), '2014-05-23 16:39:32 UTC+0000')
    dt_converted = tz.dt_as_timezone(dt, pytz.timezone("US/Pacific"))
    eq_(dt_converted.strftime('%Y-%m-%d %H:%M:%S %Z%z'),
        '2014-05-23 09:39:32 PDT-0700')
Esempio n. 2
0
def test_dt_as_timezone_aware():
    with assert_raises(ValueError):
        tz.dt_as_timezone(datetime.datetime.utcnow(),
                          pytz.timezone("US/Pacific"))
Esempio n. 3
0
def test_dt_as_timezone_invalid_object():
    tests = [list(), dict(), "20140728", '2014-05-28T01:32:42']
    for obj in tests:
        with assert_raises(ValueError):
            tz.dt_as_timezone(obj, pytz.timezone("US/Pacific"))
Esempio n. 4
0
def test_dt_as_timezone_conversions():
    dt = datetime.datetime(2014, 5, 23, 16, 39, 32, 125099, tzinfo=pytz.UTC)
    eq_(dt.strftime('%Y-%m-%d %H:%M:%S %Z%z'), '2014-05-23 16:39:32 UTC+0000')
    dt_converted = tz.dt_as_timezone(dt, pytz.timezone("US/Pacific"))
    eq_(dt_converted.strftime('%Y-%m-%d %H:%M:%S %Z%z'),
        '2014-05-23 09:39:32 PDT-0700')
Esempio n. 5
0
def test_dt_as_timezone_aware():
    with assert_raises(ValueError):
        tz.dt_as_timezone(
            datetime.datetime.utcnow(), pytz.timezone("US/Pacific"))
Esempio n. 6
0
def test_dt_as_timezone_invalid_object():
    tests = [list(), dict(), "20140728", '2014-05-28T01:32:42']
    for obj in tests:
        with assert_raises(ValueError):
            tz.dt_as_timezone(obj, pytz.timezone("US/Pacific"))