def test_260_timezone_invalid_values(self): for invalid_value in (-25, -24.000001, 24.000001, 25): with pytest.raises(ValueError): WesternTime(1, 2, 3, to_utc=invalid_value) with pytest.raises(ValueError): WesternTime.in_hours("789/123", invalid_value) with pytest.raises(ValueError): WesternTime.in_minutes("78901/123", invalid_value) with pytest.raises(ValueError): WesternTime.in_seconds("789012/123", invalid_value)
def test_002_constructor_in_hours(self): for test_row in western_time_test_data: in_hours = Fraction(test_row[2]) hour = test_row[1][0] minute = test_row[1][1] second = Fraction(test_row[1][2]) western = WesternTime.in_hours(in_hours) assert (western.hour, western.minute, western.second) == (hour, minute, second)
def test_070_timezone_valid(self): for test_to_utc in to_utc_test_data: western1 = WesternTime(1, 2, 3, to_utc=test_to_utc[0]) assert western1.to_utc == test_to_utc[1] western2 = WesternTime.in_hours("789/123", to_utc=test_to_utc[0]) assert western2.to_utc == test_to_utc[1] western2 = WesternTime.in_minutes("78901/123", to_utc=test_to_utc[0]) assert western2.to_utc == test_to_utc[1] western3 = WesternTime.in_seconds("789012/123", to_utc=test_to_utc[0]) assert western3.to_utc == test_to_utc[1]
def test_010_constructor_in_hours(self): for test_row in western_time_test_data: in_hours = Fraction(test_row[2]) hour = test_row[1][0] minute = test_row[1][1] second = Fraction(test_row[1][2]) western = WesternTime.in_hours(in_hours) assert (western.hour, western.minute, western.second) == ( hour, minute, second, )
def test_012_invalid_parameter_types_in_hours(self): # exception with none, two or four parameters with pytest.raises(TypeError): WesternTime.in_hours() with pytest.raises(TypeError): WesternTime.in_hours(1, 2) # exception with non-numeric types for invalid_hours in ((1,), [1], {1: 1}, (), [], {}, None): with pytest.raises(TypeError): WesternTime.in_hours(invalid_hours) # exception with invalid numeric types for invalid_hours in (1j, 1 + 1j, INF): with pytest.raises(TypeError): WesternTime.in_hours(invalid_hours)
def test_170_timezone_invalid(self): # exception with unknown named parameter with pytest.raises(TypeError): WesternTime(1, 2, 3, invalid=0) WesternTime.in_hours("789/123", invalid=0) WesternTime.in_minutes("78901/123", invalid=0) WesternTime.in_seconds("789012/123", invalid=0) # exception with non-numeric types for invalid_to_utc in ((1, ), [1], {1: 1}, (), [], {}): with pytest.raises(TypeError): WesternTime(1, 2, 3, to_utc=invalid_to_utc) with pytest.raises(TypeError): WesternTime.in_hours("789/123", to_utc=invalid_to_utc) with pytest.raises(TypeError): WesternTime.in_minutes("78901/123", to_utc=invalid_to_utc) with pytest.raises(TypeError): WesternTime.in_seconds("789012/123", to_utc=invalid_to_utc) # exception with invalid numeric types for invalid_to_utc in (1j, 1 + 1j, INF, NAN): with pytest.raises(TypeError): WesternTime(1, 2, 3, to_utc=invalid_to_utc) with pytest.raises(TypeError): WesternTime.in_hours("789/123", to_utc=invalid_to_utc) with pytest.raises(TypeError): WesternTime.in_minutes("78901/123", to_utc=invalid_to_utc) with pytest.raises(TypeError): WesternTime.in_seconds("789012/123", to_utc=invalid_to_utc)
def test_110_invalid_parameter_types_in_hours(self): # exception with none, two or four parameters with pytest.raises(TypeError): WesternTime.in_hours() with pytest.raises(TypeError): WesternTime.in_hours(1, 2) # exception with non-numeric types for invalid_hours in ((1, ), [1], {1: 1}, (), [], {}, None): with pytest.raises(TypeError): WesternTime.in_hours(invalid_hours) # exception with invalid numeric types for invalid_hours in (1j, 1 + 1j, INF, NAN): with pytest.raises(TypeError): WesternTime.in_hours(invalid_hours)
def test_022_invalid_values_in_hours(self): for num, denum in ((24, 1), (1, -1), (24000001, 1000000), (-1, 1000000)): with pytest.raises(ValueError): WesternTime.in_hours(Fraction(num, denum))
def test_210_invalid_values_in_hours(self): for num, denum in ((24, 1), (1, -1), (24000001, 1000000), (-1, 1000000)): with pytest.raises(ValueError): WesternTime.in_hours(Fraction(num, denum))