Created
May 20, 2014 12:40
-
-
Save dnase/7b6f299ef89ff1fcb582 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
import sys | |
if len(sys.argv) == 3: | |
names = sys.argv[1].split('.') | |
name_space = '.'.join(names[0:-1]) | |
caller = names[-2] | |
class_name = names[-1] | |
method_file = sys.argv[2] | |
#import from names as strings | |
test_lib = __import__(name_space) | |
methods = __import__(method_file) | |
else: | |
sys.exit("Usage: " + sys.argv[0] + " [name_space.ClassName] [method file.py]") | |
import inspect | |
from time import sleep | |
#Time to idle, in seconds, between requests. | |
IDLE_TIME = 1 | |
#Instantiate class | |
buff = getattr(test_lib, class_name) | |
ra = buff() | |
#Iterate through each method | |
for name, m in inspect.getmembers(getattr(test_lib, class_name), predicate=inspect.ismethod): | |
try: | |
if callable(m): | |
if name in methods.method_data.keys(): | |
print "Calling " + name + "(" + str(methods.method_data[name]) + "):" | |
m(ra, methods.method_data[name]) | |
print name + " test passed." | |
else: | |
print "Calling " + name + "():" | |
m(ra) | |
print name + " test passed." | |
else: | |
print name + ' is not a method.' | |
except: | |
print name + " test failed." | |
sleep(IDLE_TIME) | |
print "All automatic tests for " + class_name + " completed." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment