def test_430_replace(self): for test_row in gregorian_test_data[:33]: # take Calendrical Calculations tests data only (other may make replace fail, as in the next tests method) year = test_row[2][0] month = test_row[2][1] day = test_row[2][2] greg = GregorianCalendar(year, month, day) assert greg.replace() == GregorianCalendar(year, month, day) assert greg.replace(year=11) == GregorianCalendar(11, month, day) assert greg.replace(month=10) == GregorianCalendar(year, 10, day) assert greg.replace(day=9) == GregorianCalendar(year, month, 9) assert greg.replace(month=10, year=11) == GregorianCalendar(11, 10, day) assert greg.replace(day=9, year=11) == GregorianCalendar(11, month, 9) assert greg.replace(day=9, month=10) == GregorianCalendar(year, 10, 9) assert greg.replace(day=9, month=10, year=11) == GregorianCalendar(11, 10, 9)
def test_430_replace(self): for test_row in gregorian_test_data[: 33]: # take Calendrical Calculations tests data only (other may make replace fail, as in the next tests method) year = test_row[2][0] month = test_row[2][1] day = test_row[2][2] greg = GregorianCalendar(year, month, day) assert greg.replace() == GregorianCalendar(year, month, day) assert greg.replace(year=11) == GregorianCalendar(11, month, day) assert greg.replace(month=10) == GregorianCalendar(year, 10, day) assert greg.replace(day=9) == GregorianCalendar(year, month, 9) assert greg.replace(month=10, year=11) == GregorianCalendar(11, 10, day) assert greg.replace(day=9, year=11) == GregorianCalendar(11, month, 9) assert greg.replace(day=9, month=10) == GregorianCalendar(year, 10, 9) assert greg.replace(day=9, month=10, year=11) == GregorianCalendar(11, 10, 9)
def test_436_replace_invalid_values(self): greg1 = GregorianCalendar(11, 10, 9) with pytest.raises(ValueError): greg1.replace(month=0) with pytest.raises(ValueError): greg1.replace(day=0) with pytest.raises(ValueError): greg1.replace(month=-1) with pytest.raises(ValueError): greg1.replace(day=-1) with pytest.raises(ValueError): greg1.replace(month=13) with pytest.raises(ValueError): greg1.replace(day=32) for month in (4, 6, 9, 11): greg2 = GregorianCalendar(11, month, 9) with pytest.raises(ValueError): greg2.replace(day=31) greg3 = GregorianCalendar(11, 10, 31) with pytest.raises(ValueError): greg3.replace(month=month) for day in (29, 30, 31): greg4 = GregorianCalendar(11, 3, day) with pytest.raises(ValueError): greg4.replace(month=2) greg5 = GregorianCalendar(11, 2, 4) with pytest.raises(ValueError): greg5.replace(day=day) for day in (30, 31): greg6 = GregorianCalendar(4, 3, day) # leap year with pytest.raises(ValueError): greg6.replace(month=2) greg7 = GregorianCalendar(4, 2, 4) with pytest.raises(ValueError): greg7.replace(day=day)
def test_433_replace_invalid_types(self): greg = GregorianCalendar(11, 10, 9) # exception for positional parameters with pytest.raises(TypeError): greg.replace(1) # exception with non-numeric types for par in ("1", (1, ), [1], {1: 1}, (), [], {}): with pytest.raises(TypeError): greg.replace(year=par) with pytest.raises(TypeError): greg.replace(month=par) with pytest.raises(TypeError): greg.replace(day=par) # exception with invalid numeric types for par in (1.0, Fraction(1, 1), Decimal(1), 1j, 1 + 1j, INF, NAN): with pytest.raises(TypeError): greg.replace(year=par) with pytest.raises(TypeError): greg.replace(month=par) with pytest.raises(TypeError): greg.replace(day=par)
def test_433_replace_invalid_types(self): greg = GregorianCalendar(11, 10, 9) # exception for positional parameters with pytest.raises(TypeError): greg.replace(1) # exception with non-numeric types for par in ("1", (1,), [1], {1: 1}, (), [], {}): with pytest.raises(TypeError): greg.replace(year=par) with pytest.raises(TypeError): greg.replace(month=par) with pytest.raises(TypeError): greg.replace(day=par) # exception with invalid numeric types for par in (1.0, Fraction(1, 1), Decimal(1), 1j, 1 + 1j, INF, NAN): with pytest.raises(TypeError): greg.replace(year=par) with pytest.raises(TypeError): greg.replace(month=par) with pytest.raises(TypeError): greg.replace(day=par)