Created
February 18, 2016 11:36
-
-
Save not-much-io/5f0bed606996fea9c410 to your computer and use it in GitHub Desktop.
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 get_tests(test_case_class): | |
"""Gets all tests from a TestCase class. | |
:param test_case_class: A subclass of TestCase | |
:return: tests in the TestCase | |
""" | |
test_case_instance = eval(test_case_class.__name__ + "()") | |
func_type = type(lambda x: None) | |
test_methods = [] | |
for name in test_case_class.__dict__: | |
if name.startswith("test"): | |
call_expr = test_case_instance.__class__.__name__ + "." + name | |
data_type = type(eval(call_expr)) | |
if data_type == func_type: | |
test_methods.append(test_case_class(name)) | |
return test_methods |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment