I understand that I can write a doctest like:
def foo():
"""
>>> foo()
'abc'
"""
return 'abc'
However, what if my function is fetching a large HTML file? I don't want to have to put the entire contents of the returned string into the doctest. Instead I just want to be able to assert that the returned HTML includes an expected bit, something like:
"<title>The Right Page</title>" in returnedValue
Is this possible in doctests, or do I need a real unit test to check this?
Yes, it's possible. You can simply check if the result of the comparison is True
.
"""
>>> "<title>The Right Page</title>" in foo()
True
"""