Created
May 5, 2025 17:27
-
-
Save tsibley/f6ee7787431376a4d4cd4721abbd65f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import doctest | |
import sys | |
try: | |
script = sys.argv[1] | |
except IndexError: | |
sys.stderr.write(f"error: no script given\n") | |
sys.stderr.write(f"usage: {sys.argv[0]} <script>\n") | |
sys.exit(1) | |
__name__ = f"<{script}>" | |
exec(open(script).read(), globals()) | |
failed, total = doctest.testmod() | |
if failed: | |
sys.stderr.write(f"error: {failed:,} test{'s' if failed != 1 else ''} failed\n") | |
if not total: | |
sys.stderr.write(f"error: no tests found\n") | |
sys.exit(1 if failed or not total else 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment