def test_zero(self): result = ecu.get_hms(0) expected = '0:00' self.assertEqual(expected, result)
def test_negative(self): with self.assertRaises(ValueError) as cm: ecu.get_hms(-12) expected_message = 'received a negative or invalid value for seconds' exception_message = str(cm.exception) self.assertEqual(expected_message, exception_message)
def test_invalid_type(self): with self.assertRaises(TypeError) as cm: ecu.get_hms('using a string instead of a number') expected_message = 'seconds must be type int or float, received:' exception_message = str(cm.exception)[:44] self.assertEqual(expected_message, exception_message)
def test_3601(self): result = ecu.get_hms(3601) expected = '1:00:01' self.assertEqual(expected, result)
def test_float(self): expected = '12:12' result = ecu.get_hms(731.61) self.assertEqual(expected, result)
def test_3599(self): result = ecu.get_hms(3599) expected = '59:59' self.assertEqual(expected, result)
def test_61(self): result = ecu.get_hms(61) expected = '1:01' self.assertEqual(expected, result)
def test_60(self): result = ecu.get_hms(60) expected = '1:00' self.assertEqual(expected, result)
def test_59(self): result = ecu.get_hms(59) expected = '0:59' self.assertEqual(expected, result)
def test_one(self): result = ecu.get_hms(1) expected = '0:01' self.assertEqual(expected, result)