Tests are not fully executed (Possible problem in test_module.py)
Hi friends, I have my add_time() function ready. It is working fine but for some reason the tests are not being carried out through the test_module.py. It does not throw any error but the tests are not carried out either, only the one that is in the main.py module. Any ideas? I don’t know whether to deliver it like this or continue investigating. Any suggestions would be welcome. Thank you.
Regarding the code, I accept all kinds of criticisms or suggestions.
def add_time(start, duration, day=None):
days = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
add_hh, add_mm = map(int, (duration.split(':')))
tota_mm_add = add_hh*60 + add_mm
hh,mm = map(int, start.split()[0].split(':') )
if 'PM' in start: hh += 12
total_mm = hh*60 + mm
new_time_mm = total_mm + tota_mm_add
total_days = new_time_mm//1440
new_hh = (new_time_mm//60)%24
meridian = ' PM' if new_hh >= 12 else ' AM'
new_hh = str(new_hh%12)
if new_hh == '0':
new_hh = '12'
new_mm = str(new_time_mm % 60)
if len(new_mm) == 1:
new_mm = '0'+new_mm
new_time = ':'.join([new_hh, new_mm]) + meridian
if day: new_time += ', '+ days[(days.index(day.capitalize())+total_days)%7]
if total_days == 1: new_time += ' (next day)'
elif total_days > 1: new_time += f' ({total_days} days later)'
return new_time
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Challenge: Scientific Computing with Python Projects - Time Calculator
Link to the challenge: