3 from pprint import pprint
5 # Add qa root directory to the path to make
7 path = os.path.dirname(os.path.abspath(__file__))
8 path_parts = path.split(os.sep)
9 sys.path.append(os.sep.join(path_parts[:-2]))
12 from qa.logger import log
13 from qa.Config import Config
17 Base class for all QA test functions. At a minimum all tests
20 call(arg1, arg2, ...): method body
27 def call(self, *args):
29 Method body for test functions. Must override.
33 def __init__(self, config = None):
34 if not config: config = Config()
35 self.name = self.__class__.__name__
36 self.path=os.path.abspath(os.path.dirname(sys.argv[0]))
41 def __call__(self, *args, **kwds):
43 Main entry point for test functions. logs methods
46 #(min_args, max_args, defaults) = self.args()
48 # Check that the right number of arguments were passed in
49 #if len(args) < len(min_args) or len(args) > len(max_args):
50 # raise Exception#, (len(args), len(min_args), len(max_args))
52 module = self.__class__.__module__.replace(".", os.sep)
53 file = self.path + os.sep + module + ".py"
54 result = self.call(*args, **kwds)
63 ((arg1_name, arg2_name, ...),
64 (arg1_name, arg2_name, ..., optional1_name, optional2_name, ...),
65 (None, None, ..., optional1_default, optional2_default, ...))
67 That represents the minimum and maximum sets of arguments that
68 this function accepts and the defaults for the optional arguments.
71 # Inspect call. Remove self from the argument list.
72 max_args = self.call.func_code.co_varnames[1:self.call.func_code.co_argcount]
73 defaults = self.call.func_defaults
77 min_args = max_args[0:len(max_args) - len(defaults)]
78 defaults = tuple([None for arg in min_args]) + defaults
80 return (min_args, max_args, defaults)