Editor

Test a Date Checker

Write the tests · Advanced · about 15 min

is_valid_date(text) returns True when text is a real date written as DD/MM: two digits for the day, a slash, and two digits for the month, like "05/11". Months go from 01 to 12. April, June, September and November have 30 days, February always has 28 (this checker ignores leap years), and the other months have 31. Anything else returns False.

Write test_ functions with assert that pass on a correct version and fail on broken ones.

Examples

is_valid_date("05/11")    # True
is_valid_date("31/11")    # False, November has 30 days
is_valid_date("15-06")    # False, the wrong separator
def test_normal_date():
assert is_valid_date("15/06") == True
The solution opens after your first Check.