def test_months_with_31(): """ Test months with 31 days """ for item in MONTHS_WITH_31: assert days_in_month(item) == 31 # Write a test function for the months with 30 days for item in MONTHS_WITH_30: assert days_in_month(item) == 30 # Write a test function for the months with 28 or 29 days for item in MONTHS_WITH_28_or_29: assert days_in_month(item) == 28 or 29 # Write a test function for months that are not capitalized properly # Hint: use the lower() string method def test_not_capitalized(): for item in MONTHS_WITH_31: assert days_in_month(item.lower()) == 31 for item in MONTHS_WITH_30: assert days_in_month(item.lower()) == 30 for item in MONTHS_WITH_28_or_29: assert days_in_month(item.lower()) == "28 or 29"
def test_unexpected_input(): try: assert days_in_month("dog") except ValueError: return True try: assert days_in_month(%^) except ValueError: return True try: assert days_in_month(1234) except ValueError: return True try: assert days_in_month(3+4) except AttributeError: return True try: assert days_in_month(3.45) except AttributeError: return True
def test_not_capitalized(): for item in MONTHS_WITH_31: assert days_in_month(item.lower()) == 31 for item in MONTHS_WITH_30: assert days_in_month(item.lower()) == 30 for item in MONTHS_WITH_28_or_29: assert days_in_month(item.lower()) == "28 or 29"
def test_unexpected_input_number(): """ Test with unexpected input, for example 4 """ try: days_in_month("23") except ValueError: assert True
def test_value_error(): try: for item in VALUE_ERROR_TEST_LIST: days_in_month(item) except TypeError: assert True except ValueError: assert True
def test_months_with_less(): for item in MONTHS_WITH_30 or MONTHS_WITH_28_or_29: assert True try: days_in_month(item) == 30 or 29 or 28 except ValueError: assert True
def test_unexpected_input_string(): """ Test with unexpected input, for example a string other than a month """ try: days_in_month(23) except AttributeError: assert True
def test_wrong_input(): try: for item in BAD_INPUT: days_in_month(item) except ValueError: assert True except TypeError: assert True
def test_unexpected_input(): try: days_in_month("Octavian") except ValueError: assert True try: days_in_month(24601) except AttributeError: assert True
def test_unexpected_input(): for item in WEIRD_INPUT: try: days_in_month(item) except: if ValueError: assert True if TypeError: assert True
def test_month_format(): for item in MONTHS_WITH_31: assert days_in_month(item.lower()) == 31 for item in MONTHS_WITH_30: assert days_in_month(item.lower()) == 30 for item in MONTHS_WITH_28_or_29: assert days_in_month(item.lower()) == "28 or 29"
def test_error(): for item in WRONG_INPUT: try: days_in_month(item) assert False except: assert True
def test_wrong_attribute(): """ Test for wrong data types """ wrong_attributes = [1, 4.5, False, ["january", "March"]] for item in wrong_attributes: try: days_in_month(item) == False except AttributeError: assert True
def test_months_incorrect_spelling(): for item in MONTHS_WITH_30: item = item.lower() assert days_in_month(item) == 30 for item in MONTHS_WITH_31: item = item.lower() assert days_in_month(item) == 31 for item in MONTHS_WITH_28_or_29: item = item.lower() assert days_in_month(item) == "28 or 29"
def test_unexpected_input(): try: days_in_month(22) except AttributeError: assert True try: days_in_month("what") except ValueError: assert True
def test_unexpected_input(): try: for item in UNEXPECTED_INPUT: days_in_month(item) except ValueError: assert True except AttributeError: assert True except TypeError: assert True
def test_unexpected_input(): try: for item in random_input: days_in_month(item) except ValueError: assert True except TypeError: assert True except AttributeError: assert True
def unexpected_input(): try: days_in_month("kjhuy") except ValueError: assert True try: days_in_month(7) except AttributeError: assert True
def test_exception(): try: days_in_month("ychdjs") except ValueError: assert True try: days_in_month(6) except AttributeError: assert True
def test_unexpected(): try: days_in_month("abcde") except ValueError: assert True try: days_in_month(9) except AttributeError: assert True
def test_function_for_unexpected_input(): # Hint: use a try/except block to deal with the exception try: days_in_month(12) except AttributeError: assert True try: days_in_month('Stuff') except ValueError: assert True
def test_wrong_strings(): """ Test for incorrect strings """ wrong_strings = ["this", "can't", "be", "right", "12345"] for item in wrong_strings: try: days_in_month(item) except ValueError: assert True
def lower_days_in_month (): for item in MONTHS_WITH_31: item = item.lower() assert days_in_month(item) == 31 for item in MONTHS_WITH_30: item = item.lower() assert days_in_month(item) == 30 for item in MONTHS_WITH_28_or_29: item = item.lower() assert days_in_month(item) == 28 or days_in_month(item) == 29
def test_months_not_capitalized(): """ Test months not capitalized properly """ for item in MONTHS_WITH_30: assert days_in_month(item.lower()) == 30 for item in MONTHS_WITH_28_or_29: assert days_in_month(item.lower()) == 28 or 29 for item in MONTHS_WITH_31: assert days_in_month(item.lower()) == 31
def test_unexpected_input(): #testing string not found in months try: days_in_month("Elvis") except ValueError: assert True #testing inputs that are not strings try: days_in_month(20) except AttributeError: assert True
def test_bad_input(): """ Test bad inputs """ try: days_in_month("some string") except ValueError: assert True try: days_in_month(12345) except AttributeError: assert True
def test_data_type(): """ Test for data types """ try: assert days_in_month("$$$") except ValueError: return True try: assert days_in_month(123) except AssertionError: return True
def test_months_with_28_or_29(): """ Test months with 28 or 29 days """ for item in MONTHS_WITH_31: assert days_in_month(item) == 31 # Write a test function for the months with 30 days for item in MONTHS_WITH_30: assert days_in_month(item) == 30 # Write a test function for the months with 28 or 29 days for item in MONTHS_WITH_28_or_29: assert days_in_month(item) == "28 or 29"
def test_unexpected_input(): """ Testing int as input """ try: days_in_month(2) except AttributeError: assert True # Testing a string that is not a month try: days_in_month("First month") except ValueError: assert True # Testing a float try: days_in_month(10.0) except AttributeError: assert True # Testing an empty entry try: days_in_month() except TypeError: assert True
def test_unexpected_input(): """ Test unexpected input """ try: assert days_in_month("123") except ValueError: return True try: assert days_in_month(123) except AssertionError: return True
MONTHS_WITH_28_or_29_LOWER = [month.lower() for month in MONTHS_WITH_28_or_29] ======= >>>>>>> refs/remotes/benevolentprof/master def test_months_with_31(): """ Test months with 31 days """ for item in MONTHS_WITH_31: assert days_in_month(item) == 31 # Write a test function for the months with 30 days <<<<<<< HEAD for item in MONTHS_WITH_30: assert days_in_month(item) == 30 # Write a test function for the months with 28 or 29 days for item in MONTHS_WITH_28_or_29: assert days_in_month("February") == "28 or 29" ======= # Write a test function for the months with 28 or 29 days >>>>>>> refs/remotes/benevolentprof/master # Write a test function for months that are not capitalized properly # Hint: use the lower() string method
def test_months_with_31(): """ Test months with 31 days """ for item in MONTHS_WITH_31: assert days_in_month(item) == 31
def test_months_with_28_or_29_lower(): for item in MONTHS_WITH_28_or_29_LOWER: assert days_in_month(item)== "28 or 29"
def test_months_with_30_lower(): for item in MONTHS_WITH_30_LOWER: assert days_in_month(item)== 30