I have a function that prints a somewhat random string to the console, for example:
from random import choice
def hello():
print(f"Hello {choice(('Guido', 'Raymond'))}!")
Please note that my actual function is more complicated than this. The random part is a request to a database that can either succeed or fail. This means that I cannot initialize a seed to have a constant outcome.
What I have tried is to use the ellipsis, but I also need to add an ugly comment for doctest to recognize it.
def hello():
"""
>>> hello() # doctest: +ELLIPSIS
Hello ...!
"""
print(f"Hello {choice(('Guido', 'Raymond'))}!")
Is there a better strategy in this situation?
For example, instead of an ellipsis it would be great if I could test that the answer is one between Hello Guido!
and Hello Raymond!
.