-
Notifications
You must be signed in to change notification settings - Fork 0
Testing with doctest
Somkiat Puisungnoen edited this page Jun 12, 2025
·
3 revisions
import doctest
"""
Say hi to a person.
>>> say_hi("Somkiat")
Hi, Somkiat!
"""
def say_hi(name: str) -> str:
"""
Print a greeting message with the provided name.
Args:
name (str): The name to greet.
"""
return f"Hi, {name}!"
if __name__ == "__main__":
doctest.testmod() # Run the doctests in this module
$python demo.py -v
2 items had no tests:
__main__
__main__.say_hi
0 tests in 2 items.
0 passed.
Test passed.
$pydoc -p 1234