Exemplo n.º 1
0
 def _generate(self, event, name, method, testCaseClass):
     names = []
     for index, argSet in enumerate_params(method.paramList):
         method_name = util.name_from_args(name, index, argSet)
         def _method(self, method=method, argSet=argSet):
             return method(self, *argSet)
         if not hasattr(testCaseClass, method_name):
             # not already generated
             setattr(testCaseClass, method_name, _method)
         names.append(method_name)
     return names
Exemplo n.º 2
0
 def _generate(self, event, name, method, testCaseClass):
     names = []
     for index, argSet in enumerate_params(method.paramList):
         method_name = util.name_from_args(name, index, argSet)
         if not hasattr(testCaseClass, method_name):
             # not already generated
             def _method(self, method=method, argSet=argSet):
                 return method(self, *argSet)
             _method = functools.update_wrapper(_method, method)
             delattr(_method, 'paramList')
             setattr(testCaseClass, method_name, _method)
         names.append(method_name)
     return names
Exemplo n.º 3
0
 def _generateFuncTests(self, obj):
     args = {}
     setUp = getattr(obj, 'setUp', None)
     tearDown = getattr(obj, 'tearDown', None)
     if setUp is not None:
         args['setUp'] = setUp
     if tearDown is not None:
         args['tearDown'] = tearDown
     for index, argSet in enumerate_params(obj.paramList):
         def func(argSet=argSet, obj=obj):
             return obj(*argSet)
         name = '%s.%s' % (obj.__module__, obj.__name__)
         func_name = util.name_from_args(name, index, argSet)
         yield ParamsFunctionCase(func_name, func, **args)
Exemplo n.º 4
0
 def _generateFuncTests(self, obj):
     args = {}
     setUp = getattr(obj, 'setUp', None)
     tearDown = getattr(obj, 'tearDown', None)
     if setUp is not None:
         args['setUp'] = setUp
     if tearDown is not None:
         args['tearDown'] = tearDown
     for index, argSet in enumerate_params(obj.paramList):
         def func(argSet=argSet, obj=obj):
             return obj(*argSet)
         func = functools.update_wrapper(func, obj)
         delattr(func, 'paramList')
         name = '%s.%s' % (obj.__module__, obj.__name__)
         func_name = util.name_from_args(name, index, argSet)
         yield util.transplant_class(
             ParamsFunctionCase, obj.__module__)(func_name, func, **args)
Exemplo n.º 5
0
 def _testsFromGenerator(self, event, name, generator, testCaseClass):
     try:
         for index, (func, args) in self.unpack(generator):
             method_name = util.name_from_args(name, index, args)
             setattr(testCaseClass, method_name, None)
             instance = testCaseClass(method_name)
             delattr(testCaseClass, method_name)
             def method(func=func, args=args):
                 return func(*args)
             setattr(instance, method_name, method)
             yield instance
     except:
         exc_info = sys.exc_info()
         test_name = '%s.%s.%s' % (testCaseClass.__module__,
                                   testCaseClass.__name__,
                                   name)
         yield event.loader.failedLoadTests(test_name, exc_info)
Exemplo n.º 6
0
    def _testsFromGenerator(self, event, name, generator, testCaseClass):
        try:
            for index, (func, args) in self.unpack(generator):
                method_name = util.name_from_args(name, index, args)
                setattr(testCaseClass, method_name, None)
                instance = testCaseClass(method_name)
                delattr(testCaseClass, method_name)

                def method(func=func, args=args):
                    return func(*args)

                method = functools.update_wrapper(method, func)
                setattr(instance, method_name, method)
                yield instance
        except Exception as e:
            test_name = '%s.%s.%s' % (testCaseClass.__module__,
                                      testCaseClass.__name__, name)
            yield event.loader.failedLoadTests(test_name, e)
Exemplo n.º 7
0
    def _testsFromGenerator(self, event, name, generator, testCaseClass):
        try:
            for index, (func, args) in self.unpack(generator):
                method_name = util.name_from_args(name, index, args)
                setattr(testCaseClass, method_name, None)
                instance = testCaseClass(method_name)
                delattr(testCaseClass, method_name)

                def method(func=func, args=args):
                    return func(*args)
                method = functools.update_wrapper(method, func)
                setattr(instance, method_name, method)
                yield instance
        except Exception as e:
            test_name = '%s.%s.%s' % (testCaseClass.__module__,
                                      testCaseClass.__name__,
                                      name)
            yield event.loader.failedLoadTests(test_name, e)