Some help for unitTest in replit

I have this final code in a project that must return a string output

if day == " ":
        if n_day  == 0:
            string = final_time.strip()
            return string
            return f"{final_time} {label_day}"
        if n_day  == 0:
            return f"{final_time}, {day.title()}"
            return  f"{final_time}, {final_day} {label_day}"

my code is test in local machine in VsCode : it run with out any problem
but in replit platform show this error message with UnitTest
self.assertEqual(actual, expected, ‘Expected period to change from AM to PM at 12:00’)
AssertionError: '12:05 PM, ’ != ‘12:05 PM’

  • 12:05 PM,
    ? –
  • 12:05 PM
    : Expected period to change from AM to PM at 12:00

the problem is the " , " .
any idea about this problem with unittest in python 3.10

I have found the solution
the code is a function that accept 3 argument
day is an optional argument it(s a string variable
the first condition must be :
if day == “”

and the problem is resolved

because if i use a condition like :
if day == " " this condition affect a space to the optional function argument day.
and the unittest is testing a string output so there is a n optional space added to the output result

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.