Python Doctest Syntax requiring blanks after? blanks already included

75 Views Asked by At

I am trying to run a Doctest which is returning the following Syntax related error when running Python -m doctest


ValueError: line 4 of the docstring for app.check_valid_curr lacks blank after >>>: '   >>>check_valid_curr("EUR,"USD")'

Here is the function in question, with docstring and doctest included

def check_valid_curr(currency_code_from, currency_code_to):
   """checks if the currency codes inputted are valid

   >>>check_valid_curr("EUR,"USD")
   True

   >>>check_valid_curr("EUR","ZMW")
   True

   """
#asking stack overflow for issue here

   if set([currency_code_from,currency_code_to]).issubset(currency_list):
      return True
   else:
      return False

When I tried the same format with a test function I made to see if it works in an other setting.

def adder(a,b):
    """adds two numbers

    >>>adder(2,1)
    3

    >>>adder(3,2)
    5
    
    """
    return a + b

There was no problem, I am wondering what I am doing wrong with the first doctest. as It runs in Ipython with correct results, I just want to be able to render the doctest working for my project.

Appreciate your help!

I tried to run the doctest, and expected either the tests to pass or fail the test, and not raise a value error.

0

There are 0 best solutions below