Exemple #1
0
    def test_410_relocate_invalid_type(self):
        """Return another Time instance that identifies the same time"""
        # relocate on naive instance
        t1 = Time("123/456")
        with pytest.raises(TypeError):
            t1.relocate("1/7")

        class WrongObj:
            def __init__(self):
                self.time_to_utc = "foo"

        t2 = Time("123/456", to_utc="-78/90")

        # exception with invalid parameter name
        with pytest.raises(TypeError):
            t2.relocate()
        with pytest.raises(TypeError):
            t2.relocate(1, 2)
        with pytest.raises(TypeError):
            t2.relocate(foobar="barfoo")

        # exception with non-numeric types
        for par in (1j, (1,), [1], {1: 1}, [], {}, None, (1, 2, 3), WrongObj()):
            with pytest.raises(TypeError):
                t2.relocate(par)
 def test_400_relocate(self):
     "Return another Time instance that identifies the same time"
     # Im using a mix of values, then check that relocated instance is equal
     for day_frac, time_input_values in time_test_data:
         for to_utc_frac, utc_input_values in to_utc_test_data:
             first = Time(time_input_values[0], to_utc=utc_input_values[0])
             for new_utc_value in to_utc_strange_test_data:
                 second = first.relocate(new_utc_value)
                 diff = (first.day_frac + first.to_utc) - (second.day_frac + second.to_utc)
                 # Note that for some of the test value we have an overflow/underflow,
                 # so we must impement a precise test
                 assert diff == int(diff)
Exemple #3
0
 def test_400_relocate(self):
     """Return another Time instance that identifies the same time"""
     # Im using a mix of values, then check that relocated instance is equal
     for day_frac, time_input_values in time_test_data:
         for to_utc_frac, utc_input_values in to_utc_test_data:
             first = Time(time_input_values[0], to_utc=utc_input_values[0])
             for new_utc_value in to_utc_strange_test_data:
                 second = first.relocate(new_utc_value)
                 diff = (first.day_frac + first.to_utc) - (
                         second.day_frac + second.to_utc
                 )
                 # Note that for some of the test value we have an overflow/underflow,
                 # so we must implement a precise test
                 assert diff == int(diff)  # ????
    def test_410_relocate_invalid_type(self):
        "Return another Time instance that identifies the same time"
        class WrongObj:
            def __init__(self):
                self.time_to_utc = 'foo'

        t = Time('123/456', to_utc='-78/90')

        # exception with invalid parameter name
        with pytest.raises(TypeError):
            t.relocate()
        with pytest.raises(TypeError):
            t.relocate(1, 2)
        with pytest.raises(TypeError):
            t.relocate(foobar='barfoo')

        # exception with non-numeric types
        for par in (1j, (1,), [1], {1:1}, [], {}, None, (1,2,3), WrongObj()):
            with pytest.raises(TypeError):
                t.relocate(par)