def test_string_date_only(self): """ Test the parse_date function which is used in the checks for datetime """ value = parse_date("2019-10-1") assert datetime(2019, 10, 1) == value # Test for odd issue that came up with casting a value twice value = parse_date("2019-10-1 10:00") value = parse_date(value) assert datetime(2019, 10, 1, 10) == value
def test_parse_date_fails_with_unknown_string(self): with pytest.raises(TypeError): parse_date("10 F")
def test_parse_date_fails_int(self): with pytest.raises(TypeError): parse_date(10)
def test_parse_date_date(self): to_convert = date(2019, 10, 1) expected = datetime(2019, 10, 1) value = parse_date(to_convert) assert value == expected
def test_tz_unaware_return_with_tz_info_given(self): value = parse_date("2019-10-1 10:00 MST") assert value.tzinfo is None
def test_tz_unaware_return(self): value = parse_date("2019-10-1 10:00") assert value.tzinfo is None
def test_string_with_tz_info_in_utc(self): value = parse_date("2019-10-1 10:00 MST") assert datetime(2019, 10, 1, 17) == value