@@ -703,14 +703,25 @@ def test_timepoint_plus_float_time_duration_day_of_month_type():
703
703
assert isinstance (time_point .day_of_month , int )
704
704
705
705
706
- def test_timepoint_subtract ():
706
+ @pytest .mark .parametrize (
707
+ 'test_props1, test_props2, ctrl_string' , get_timepoint_subtract_tests ()
708
+ )
709
+ def test_timepoint_subtract (test_props1 , test_props2 , ctrl_string ):
707
710
"""Test subtracting one time point from another."""
708
- for test_props1 , test_props2 , ctrl_string in (
709
- get_timepoint_subtract_tests ()):
710
- point1 = data .TimePoint (** test_props1 )
711
- point2 = data .TimePoint (** test_props2 )
712
- test_string = str (point1 - point2 )
713
- assert test_string == ctrl_string
711
+ point1 = TimePoint (** test_props1 )
712
+ point2 = TimePoint (** test_props2 )
713
+ test_string = str (point1 - point2 )
714
+ assert test_string == ctrl_string
715
+
716
+
717
+ def test_timepoint_subtract_truncated ():
718
+ """Test an error is raised if subtracting a truncated TimePoint from
719
+ a non-truncated one and vice versa."""
720
+ msg = r"Invalid subtraction"
721
+ with pytest .raises (ValueError , match = msg ):
722
+ TimePoint (year = 2000 ) - TimePoint (day_of_month = 2 , truncated = True )
723
+ with pytest .raises (ValueError , match = msg ):
724
+ TimePoint (day_of_month = 2 , truncated = True ) - TimePoint (year = 2000 )
714
725
715
726
716
727
@pytest .mark .parametrize ('test' , get_duration_subtract_tests ())
@@ -875,6 +886,11 @@ def test_timepoint_duration_subtract(test):
875
886
),
876
887
data .TimePoint (year = 3200 , month_of_year = 2 , day_of_month = 29 ),
877
888
),
889
+ add_param (
890
+ data .TimePoint (year = 3012 , month_of_year = 10 , hour_of_day = 9 ),
891
+ data .TimePoint (day_of_year = 63 , truncated = True ),
892
+ data .TimePoint (year = 3013 , day_of_year = 63 ),
893
+ ),
878
894
],
879
895
)
880
896
def test_timepoint_add (
0 commit comments