Last active
September 29, 2020 01:33
-
-
Save inactivist/8b7795fe5922e20083d68cadf72dc390 to your computer and use it in GitHub Desktop.
Helper function to find and run all functions prefixed with test_* in current module
This file contains 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
def run_all_tests(): | |
# pytest would be nicer | |
import types | |
for name, member in globals().items(): # NB: not iteritems() | |
if isinstance(member, types.FunctionType) and name.startswith("test_"): | |
print("Run test:", member.__name__) | |
member() | |
if __name__ == "__main__": | |
run_all_tests() | |
print("*** All tests pass ***") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment