def test_30s_printed(): """Check ClockTime imprint()""" ct = ClockTime(0, 0, 30, context={'h': 'h', 'min': '', 's': '', 'display_0h': False, 'display_0min': False, 'min_if_0h': ' min ', 's_if_0h_0min': ' s'}) assert ct.printed == '30 s'
def test_instanciation_error(): """Check the ClockTime class initialization""" with pytest.raises(TypeError) as excinfo: ClockTime(15.2, 24, 16) assert str(excinfo.value) == 'hour, minute and second must be '\ '<class \'int\'>. Found <class \'float\'>, <class \'int\'> and '\ '<class \'int\'> instead.'
def test_1h_04min_printed(): """Check ClockTime imprint()""" ct = ClockTime(1, 4, 0, context={'h': 'h', 'min': '', 's': '', 'display_0h': False, 'display_0min': True, 'display_s': False, 'min_if_0h': ' min ', 's_if_0h_0min': ' s'}) assert ct.printed == '1h04'
def test_custom_context_clocktime_printed(): """Check ClockTime imprint()""" ct = ClockTime(15, 24, 16, context={'h': 'h ', 'min': '', 's': '', 'display_s': False}) assert ct.printed == '15h 24'
def test_0h_24min_30s_printed(): """Check ClockTime imprint()""" ct = ClockTime(0, 24, 30) assert ct.printed == '0:24:30'
def test_subtraction(): """Check ClockTime __sub__()""" assert ClockTime(6, 39, 25) - ClockTime(2, 41, 26) \ == ClockTime(3, 57, 59)
def test_exceeding_day_subtraction(): """Check ClockTime __sub__()""" assert ClockTime(5, 20, 40) - ClockTime(21, 30, 0) \ == ClockTime(7, 50, 40)
def test_negative_minute_and_second_instanciation(): """Check the ClockTime class initialization""" t = ClockTime(15, -24, -16) assert str(t) == '14:35:44'
def test_repr(): """Check ClockTime __repr__()""" assert repr(ClockTime(23, 6, 3)) == 'ClockTime(23:06:03)'
def ct(): return ClockTime(15, 24, 16) def test_config_global_context():
def test_greater_than(): """Check ClockTime __gt__()""" t1 = ClockTime(23, 6, 3) t2 = ClockTime(23, 6, 4) assert t2 > t1
def test_addition_error(): """Check ClockTime __add__()""" with pytest.raises(TypeError) as excinfo: ClockTime(6, 39, 25) + (3, 50, 44) assert str(excinfo.value) == 'Only a ClockTime can be added to a '\ 'ClockTime. Found <class \'tuple\'> instead.'
def test_regular_addition(): """Check ClockTime __add__()""" assert ClockTime(6, 39, 25) + ClockTime(0, 11, 12) \ == ClockTime(6, 50, 37)
def test_lower_or_equal(): """Check ClockTime __le__()""" t1 = ClockTime(23, 6, 3) t2 = ClockTime(23, 6, 4) assert t1 <= t2
def test_greater_or_equal(): """Check ClockTime __ge__()""" t1 = ClockTime(23, 6, 3) t2 = ClockTime(23, 6, 4) assert t2 >= t1
def test_lower_than(): """Check ClockTime __lt__()""" t1 = ClockTime(23, 6, 3) t2 = ClockTime(23, 6, 4) assert t1 < t2
def test_inequality(): """Check ClockTime __eq__()""" assert ClockTime(23, 6, 3) != 'ClockTime(23:06:03)'
def test_instanciation_from_another_clocktime(ct): """Check the ClockTime class initialization""" ct2 = ClockTime(ct) assert str(ct2) == '15:24:16'
def test_addition(): """Check ClockTime __add__()""" assert ClockTime(6, 39, 25) + ClockTime(3, 50, 44) \ == ClockTime(10, 30, 9)
def test_equality(): """Check ClockTime __eq__()""" t1 = ClockTime(23, 6, 3) t2 = ClockTime(23, 6, 3) assert t1 == t2
def test_exceeding_day_addition(): """Check ClockTime __add__()""" assert ClockTime(21, 30, 0) + ClockTime(5, 20, 40) \ == ClockTime(2, 50, 40)
def test_subtraction_error(): """Check ClockTime __sub__()""" with pytest.raises(TypeError) as excinfo: ClockTime(6, 39, 25) - (3, 50, 44) assert str(excinfo.value) == 'Only a ClockTime can be subtracted from a '\ 'ClockTime. Found <class \'tuple\'> instead.'
def test_negative_second_instanciation(): """Check the ClockTime class initialization""" t = ClockTime(15, 24, -16) assert str(t) == '15:23:44'
def test_regular_subtraction(): """Check ClockTime __sub__()""" assert ClockTime(6, 39, 25) - ClockTime(0, 11, 12) \ == ClockTime(6, 28, 13)
def test_negative_instanciation(): """Check the ClockTime class initialization""" t = ClockTime(-15, -24, -16) assert str(t) == '08:35:44'
def test_leading_zeros(): """Check leading zeros""" assert str(ClockTime(1, 2, 9)) == '01:02:09'