I am using doctest.testmod()
to do some basic testing. I have a function that returns a long string, say get_string()
. Something like:
def get_string(a, b):
r''' (a, b) -> c
>>> get_string(1, 2)
'This is \n\n a long \n string with new \
space characters \n\n'
# Doctest should work but does not.
'''
return ('This is \n\n a long \n string ' + \
'with new space characters \n\n')
The problem is that the doctest is not passing because it is expecting a single line string, and it is treating the wrap as a \n
character. Is there a way to get around this?
PS: This is not the actual function I am working with, but a minimal version for your sake.
return
line the backslash is useless if not harmful. Parenthesis are enough for continuing lines (and they should be preferred anyway). Besides, even the+
is superfluous. – Ory