def test_450_replace(self): for test_row in western_time_test_data: hour = test_row[1][0] minute = test_row[1][1] second = Fraction(test_row[1][2]) western = WesternTime(hour, minute, second) assert western.replace() == WesternTime(hour, minute, second) assert western.replace(hour=11) == WesternTime(11, minute, second) assert western.replace(minute=10) == WesternTime(hour, 10, second) assert western.replace(second=9) == WesternTime(hour, minute, 9) assert western.replace(minute=10, hour=11) == WesternTime(11, 10, second) assert western.replace(second=9, hour=11) == WesternTime(11, minute, 9) assert western.replace(second=9, minute=10) == WesternTime(hour, 10, 9) assert western.replace(second=9, minute=10, hour=11) == WesternTime(11, 10, 9)
def test_650_replace(self): for test_row in western_time_test_data: hour = test_row[1][0] minute = test_row[1][1] second = Fraction(test_row[1][2]) western = WesternTime(hour, minute, second) assert western.replace() == WesternTime(hour, minute, second) assert western.replace(hour=11) == WesternTime(11, minute, second) assert western.replace(minute=10) == WesternTime(hour, 10, second) assert western.replace(second=9) == WesternTime(hour, minute, 9) assert western.replace(minute=10, hour=11) == WesternTime(11, 10, second) assert western.replace(second=9, hour=11) == WesternTime(11, minute, 9) assert western.replace(second=9, minute=10) == WesternTime(hour, 10, 9) assert western.replace(second=9, minute=10, hour=11) == WesternTime(11, 10, 9)
def test_436_replace_invalid_values(self): western1 = WesternTime(11, 10, 9) with pytest.raises(ValueError): western1.replace(hour=-1) with pytest.raises(ValueError): western1.replace(minute=-1) with pytest.raises(ValueError): western1.replace(second=-1) with pytest.raises(ValueError): western1.replace(hour=24) with pytest.raises(ValueError): western1.replace(minute=60) with pytest.raises(ValueError): western1.replace(second=60) with pytest.raises(ValueError): western1.replace(second=NAN)
def test_433_replace_invalid_types(self): western = WesternTime(11, 10, 9) # exception for positional parameters with pytest.raises(TypeError): western.replace(1) # exception with non-numeric types for par in ("1", (1,), [1], {1: 1}, (), [], {}): with pytest.raises(TypeError): western.replace(hour=par) with pytest.raises(TypeError): western.replace(minute=par) for par in ((1,), [1], {1: 1}, (), [], {}): with pytest.raises(TypeError): western.replace(second=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): western.replace(hour=par) with pytest.raises(TypeError): western.replace(minute=par) for par in (1j, 1 + 1j, INF): with pytest.raises(TypeError): western.replace(second=par)
def test_656_replace_invalid_values(self): western1 = WesternTime(11, 10, 9) with pytest.raises(ValueError): western1.replace(hour=-1) with pytest.raises(ValueError): western1.replace(minute=-1) with pytest.raises(ValueError): western1.replace(second=-1) with pytest.raises(ValueError): western1.replace(hour=24) with pytest.raises(ValueError): western1.replace(minute=60) with pytest.raises(ValueError): western1.replace(second=60) with pytest.raises(TypeError): western1.replace(second=NAN)
def test_653_replace_invalid_types(self): western = WesternTime(11, 10, 9) # exception for positional parameters with pytest.raises(TypeError): western.replace(1) # exception with non-numeric types for par in ("1", (1, ), [1], {1: 1}, (), [], {}): with pytest.raises(TypeError): western.replace(hour=par) with pytest.raises(TypeError): western.replace(minute=par) for par in ((1, ), [1], {1: 1}, (), [], {}): with pytest.raises(TypeError): western.replace(second=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): western.replace(hour=par) with pytest.raises(TypeError): western.replace(minute=par) for par in (1j, 1 + 1j, INF): with pytest.raises(TypeError): western.replace(second=par)