-1

how can i unit test this function:?

1)

def date_of_the_task():
    print("Date of the task")
    print("Please use DD/MM/YYYY format:")
    task_date = input("> ")
    try:
        datetime.datetime.strptime(task_date, '%d/%m/%Y')
    except ValueError:
        print("Incorrect data format, should be DD/MM/YYYY!")
        input("Press enter to continue")
        date_of_the_task()
    return task_date

Thank you for you help.

Best,

Filip

Hudec
  • 11
  • 2

1 Answers1

0

Try capture the standard output using this. This method will store every call to standard out in a list.

Then test normally by asserting that the contents of the output matches what you expect.

scowan
  • 77
  • 7