Ejemplo n.º 1
0
def test_month_length():
    #these loops will test all the months
    for _ in ["September", "April", "June", "November"]:
        assert specs.month_length(_) == 30, "30 day month error"
    for _ in [
            "January", "March", "May", "July", "August", "October", "December"
    ]:
        assert specs.month_length(_) == 31, "31 day month error"
    assert specs.month_length("February",
                              False) == 28, "feb, non leap year error"
    assert specs.month_length("February", True) == 29, "leap year error, feb"
    #make sure to test the case when an unexpected string is passed through the function
    assert specs.month_length("not month string") is None, "Not month tested"
Ejemplo n.º 2
0
def test_month_length():
    """Tests getting month length for various months and years"""
    assert specs.month_length('January', True) == 31, "Failed on leap-year Jan"
    assert specs.month_length('February',
                              True) == 29, "Failed on leap-year Jan"
    assert specs.month_length('March', True) == 31, "Failed on leap-year Jan"
    assert specs.month_length('April', True) == 30, "Failed on leap-year Jan"
    assert specs.month_length('May', True) == 31, "Failed on leap-year Jan"
    assert specs.month_length('June', True) == 30, "Failed on leap-year Jan"
    assert specs.month_length('July', True) == 31, "Failed on leap-year Jan"
    assert specs.month_length('August', True) == 31, "Failed on leap-year Jan"
    assert specs.month_length('September',
                              True) == 30, "Failed on leap-year Jan"
    assert specs.month_length('October', True) == 31, "Failed on leap-year Jan"
    assert specs.month_length('November',
                              True) == 30, "Failed on leap-year Jan"
    assert specs.month_length('December',
                              True) == 31, "Failed on leap-year Jan"
    assert specs.month_length('January') == 31, "Failed on non-leap-year Jan"
    assert specs.month_length('February') == 28, "Failed on non-leap-year Jan"
    assert specs.month_length('March') == 31, "Failed on non-leap-year Jan"
    assert specs.month_length('April') == 30, "Failed on non-leap-year Jan"
    assert specs.month_length('May') == 31, "Failed on non-leap-year Jan"
    assert specs.month_length('June') == 30, "Failed on non-leap-year Jan"
    assert specs.month_length('July') == 31, "Failed on non-leap-year Jan"
    assert specs.month_length('August') == 31, "Failed on non-leap-year Jan"
    assert specs.month_length('September') == 30, "Failed on non-leap-year Jan"
    assert specs.month_length('October') == 31, "Failed on non-leap-year Jan"
    assert specs.month_length('November') == 30, "Failed on non-leap-year Jan"
    assert specs.month_length('December') == 31, "Failed on non-leap-year Jan"
    assert specs.month_length(
        'Not a month',
        True) == None, "Failed on non-month leap-year"  #tests non-month
    assert specs.month_length(
        'Not a month') == None, "Failed on non-month non-leap-year"
def test_month_length():
    #test cases for conditions
    assert specs.month_length("September") == 30
    assert specs.month_length("April") == 30
    assert specs.month_length("June") == 30
    assert specs.month_length("November") == 30
    assert specs.month_length("January") == 31
    assert specs.month_length("March") == 31
    assert specs.month_length("May") == 31
    assert specs.month_length("July") == 31
    assert specs.month_length("August") == 31
    assert specs.month_length("October") == 31
    assert specs.month_length("December") == 31
    assert specs.month_length("February") == 28
    assert specs.month_length("February", True) == 29
    assert specs.month_length("Febr", True) == None
Ejemplo n.º 4
0
def test_month_length():
    assert specs.month_length(5) == None, "failed for invalid input"
    assert specs.month_length("April") == 30, "failed on April for set of months with 30 days"
    assert specs.month_length("August") == 31, "failed on August for set of months with 31 days"
    assert specs.month_length("February") == 28, "failed on February for non leap year"
    assert specs.month_length("February", leap_year=True) == 29, "failed on February for leap year"
Ejemplo n.º 5
0
def test_month_length():
    assert specs.month_length("September") == 30, "failed on 30"
    assert specs.month_length("December") == 31, "failed on 31"
    assert specs.month_length("February") == 28, "failed on 28"
    assert specs.month_length("February", True) == 29, "failed on leap year"
    assert specs.month_length("sup") == None, "failed on incorrect month name"