def test_from_rfc3339_nanos_is_deprecated(): value = "2009-12-17T12:44:32.123456Z" result = datetime_helpers.from_rfc3339(value) result_nanos = datetime_helpers.from_rfc3339_nanos(value) assert result == result_nanos
def test_from_rfc3339_nanos_with_truncated_nanos(truncated, micros): value = "2009-12-17T12:44:32.{}Z".format(truncated) assert datetime_helpers.from_rfc3339_nanos(value) == datetime.datetime( 2009, 12, 17, 12, 44, 32, micros, pytz.utc)
def test_from_rfc3339_nanos_with_bad_tz(): value = "2009-12-17T12:44:32.123456789BAD" with pytest.raises(ValueError): datetime_helpers.from_rfc3339_nanos(value)
def test_from_rfc3339_nanos_without_nanos(): value = "2009-12-17T12:44:32Z" assert datetime_helpers.from_rfc3339_nanos(value) == datetime.datetime( 2009, 12, 17, 12, 44, 32, 0, pytz.utc)
def test_from_rfc3339_nanos_without_nanos(): value = "2009-12-17T12:44:32Z" assert datetime_helpers.from_rfc3339_nanos(value) == datetime.datetime( 2009, 12, 17, 12, 44, 32, 0, pytz.utc )
def test_from_rfc3339_nanos_with_truncated_nanos(truncated, micros): value = "2009-12-17T12:44:32.{}Z".format(truncated) assert datetime_helpers.from_rfc3339_nanos(value) == datetime.datetime( 2009, 12, 17, 12, 44, 32, micros, pytz.utc )
def test_from_rfc3339_nanos_with_bad_tz(): value = "2009-12-17T12:44:32.123456789BAD" with pytest.raises(ValueError): datetime_helpers.from_rfc3339_nanos(value)
def test_from_rfc3339_nanos(): value = "2009-12-17T12:44:32.123456Z" assert datetime_helpers.from_rfc3339_nanos(value) == datetime.datetime( 2009, 12, 17, 12, 44, 32, 123456, datetime.timezone.utc )