Changeset - bb391ccef19e
[Not reviewed]
default
0 1 0
timeless@gmail.com - 10 years ago 2016-05-03 14:10:32
timeless@gmail.com
spelling: precisely
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/parameterized.py
Show inline comments
 
@@ -60,49 +60,49 @@ def parameterized(input):
 
        if any(issubclass(cls, TestCase) for cls in parent_classes):
 
            raise Exception("Warning: '@parameterized' tests won't work "
 
                            "inside subclasses of 'TestCase' - use "
 
                            "'@parameterized.expand' instead")
 

	
 
        @wraps(f)
 
        def parameterized_helper_method(self=None):
 
            if self is not None and not attached_instance_method[0]:
 
                # confusingly, we need to create a named instance method and
 
                # attach that to the class...
 
                cls = self.__class__
 
                im_f = new.instancemethod(f, None, cls)
 
                setattr(cls, f.__name__, im_f)
 
                attached_instance_method[0] = True
 
            for args in input:
 
                if isinstance(args, basestring):
 
                    args = [args]
 
                # ... then pull that named instance method off, turning it into
 
                # a bound method ...
 
                if self is not None:
 
                    args = [getattr(self, f.__name__)] + list(args)
 
                else:
 
                    args = [f] + list(args)
 
                # ... then yield that as a tuple. If those steps aren't
 
                # followed precicely, Nose gets upset and doesn't run the test
 
                # followed precisely, Nose gets upset and doesn't run the test
 
                # or doesn't run setup methods.
 
                yield tuple(args)
 

	
 
        f.__name__ = "_helper_for_%s" % (f.__name__,)
 
        parameterized_helper_method.parameterized_input = input
 
        parameterized_helper_method.parameterized_func = f
 
        return parameterized_helper_method
 

	
 
    return parameterized_helper
 

	
 

	
 
def to_safe_name(s):
 
    return re.sub("[^a-zA-Z0-9_]", "", s)
 

	
 

	
 
def parameterized_expand_helper(func_name, func, args):
 
    def parameterized_expand_helper_helper(self=()):
 
        if self != ():
 
            self = (self,)
 
        return func(*(self + args))
 
    parameterized_expand_helper_helper.__name__ = str(func_name)
 
    return parameterized_expand_helper_helper
 

	
 

	
0 comments (0 inline, 0 general)