Beispiel #1
0
 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_004_constructor_in_minutes(self):
     for test_row in western_time_test_data:
         in_minutes = Fraction(test_row[3])
         hour = test_row[1][0]
         minute = test_row[1][1]
         second = Fraction(test_row[1][2])
         western = WesternTime.in_minutes(in_minutes)
         assert (western.hour, western.minute, western.second) == (hour, minute, second)
Beispiel #3
0
 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]
Beispiel #4
0
 def test_020_constructor_in_minutes(self):
     for test_row in western_time_test_data:
         in_minutes = Fraction(test_row[3])
         hour = test_row[1][0]
         minute = test_row[1][1]
         second = Fraction(test_row[1][2])
         western = WesternTime.in_minutes(in_minutes)
         assert (western.hour, western.minute, western.second) == (
             hour,
             minute,
             second,
         )
 def test_014_invalid_parameter_types_in_minutes(self):
     # exception with none, two or four parameters
     with pytest.raises(TypeError):
         WesternTime.in_minutes()
     with pytest.raises(TypeError):
         WesternTime.in_minutes(1, 2)
     # exception with non-numeric types
     for invalid_minutes in ((1,), [1], {1: 1}, (), [], {}, None):
         with pytest.raises(TypeError):
             WesternTime.in_minutes(invalid_minutes)
     # exception with invalid numeric types
     for invalid_minutes in (1j, 1 + 1j, INF):
         with pytest.raises(TypeError):
             WesternTime.in_minutes(invalid_minutes)
Beispiel #6
0
    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)
Beispiel #7
0
 def test_120_invalid_parameter_types_in_minutes(self):
     # exception with none, two or four parameters
     with pytest.raises(TypeError):
         WesternTime.in_minutes()
     with pytest.raises(TypeError):
         WesternTime.in_minutes(1, 2)
     # exception with non-numeric types
     for invalid_minutes in ((1, ), [1], {1: 1}, (), [], {}, None):
         with pytest.raises(TypeError):
             WesternTime.in_minutes(invalid_minutes)
     # exception with invalid numeric types
     for invalid_minutes in (1j, 1 + 1j, INF, NAN):
         with pytest.raises(TypeError):
             WesternTime.in_minutes(invalid_minutes)
 def test_024_invalid_values_in_minutes(self):
     for num, denum in ((1440, 1), (1, -1), (1440000001, 1000000), (-1, 1000000)):
         with pytest.raises(ValueError):
             WesternTime.in_minutes(Fraction(num, denum))
Beispiel #9
0
 def test_220_invalid_values_in_minutes(self):
     for num, denum in ((1440, 1), (1, -1), (1440000001, 1000000),
                        (-1, 1000000)):
         with pytest.raises(ValueError):
             WesternTime.in_minutes(Fraction(num, denum))