示例#1
0
def test_relative_time(relative):
    relative_dur = Minutes(int(relative))
    expected = Time(*now()) + relative_dur

    result = from_user_time(relative, cutoff_time(7))

    assert_that(result, equal_to(expected))
示例#2
0
def test_rejects_bad_time1():
    time_text = "24:10"
    try:
        result = from_user_time(time_text, cutoff_time(7))
        raise AssertionError(
            "Expected to see a ValueError that the time is invalid")
    except ValueError:
        pass
示例#3
0
def test_rejects_bad_ampm3():
    time_text = "13:30AM"
    try:
        result = from_user_time(time_text, cutoff_time(7))
        raise AssertionError(
            f"Expected to see a ValueError that the time is invalid, but got {result}"
        )
    except ValueError:
        pass
示例#4
0
def test_cutoff_before():
    time_text = "6:59"
    result = from_user_time(time_text, cutoff_time(7))

    assert_that(result, equal_to(Time(18, 59)))
示例#5
0
def test_cutoff_after():
    time_text = "7:15"
    result = from_user_time(time_text, cutoff_time(7))

    assert_that(result, equal_to(Time(7, 15)))
示例#6
0
def test_24_hour():
    time_text = "14:34"
    result = from_user_time(time_text, cutoff_time(7))

    assert_that(result, equal_to(Time(14, 34)))
示例#7
0
def test_semicolon_separator():
    time_text = "4;15"
    result = from_user_time(time_text, cutoff_time(7))

    assert_that(result, equal_to(Time(16, 15)))
示例#8
0
def test_dot_separator():
    time_text = "12.10"
    result = from_user_time(time_text, cutoff_time(7))

    assert_that(result, equal_to(Time(12, 10)))