Skip to content

Commit 7e4b9b7

Browse files
committed
Plug coverage holes
1 parent f2e769d commit 7e4b9b7

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

metomi/isodatetime/tests/test_01.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -703,14 +703,25 @@ def test_timepoint_plus_float_time_duration_day_of_month_type():
703703
assert isinstance(time_point.day_of_month, int)
704704

705705

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):
707710
"""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)
714725

715726

716727
@pytest.mark.parametrize('test', get_duration_subtract_tests())
@@ -875,6 +886,11 @@ def test_timepoint_duration_subtract(test):
875886
),
876887
data.TimePoint(year=3200, month_of_year=2, day_of_month=29),
877888
),
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+
),
878894
],
879895
)
880896
def test_timepoint_add(

0 commit comments

Comments
 (0)