class documentation

class parameterized:

View In Hierarchy

Parameterize a test case:

class TestInt:
@parameterized([
("A", 10), ("F", 15), param("10", 42, base=42)

]) def test_int(self, input, expected, base=16):

actual = int(input, base=base) assert_equal(actual, expected)
@parameterized([
(2, 3, 5) (3, 5, 8),

]) def test_add(a, b, expected):

assert_equal(a + b, expected)
Class Method check​_input​_values Undocumented
Class Method expand No summary
Class Method input​_as​_callable Undocumented
Class Method param​_as​_standalone​_func Undocumented
Class Method to​_safe​_name Undocumented
Method __call__ Undocumented
Method __init__ Undocumented
Method ​_terrible​_magic​_get​_defining​_classes No summary
Method assert​_not​_in​_testcase​_subclass Undocumented
Method param​_as​_nose​_tuple Undocumented
Instance Variable doc​_func Undocumented
Instance Variable get​_input Undocumented
@classmethod
def check_input_values(cls, input_values):

Undocumented

@classmethod
def expand(cls, input, name_func=None, doc_func=None, **legacy):

A "brute force" method of parameterizing test cases. Creates new test cases and injects them into the namespace that the wrapped function is being defined in. Useful for parameterizing tests in subclasses of 'UnitTest', where Nose test generators don't work.

>>> @parameterized.expand([("foo", 1, 2)])
... def test_add1(name, input, expected):
...     actual = add1(input)
...     assert_equal(actual, expected)
...
>>> locals()
... 'test_add1_foo_0': <function ...> ...
>>>
@classmethod
def input_as_callable(cls, input):

Undocumented

@classmethod
def param_as_standalone_func(cls, p, func, name):

Undocumented

@classmethod
def to_safe_name(cls, s):

Undocumented

def __call__(self, test_func):

Undocumented

def __init__(self, input, doc_func=None):

Undocumented

def _terrible_magic_get_defining_classes(self):
Returns the list of parent classes of the class currently being defined. Will likely only work if called from the parameterized decorator. This function is entirely @brandon_rhodes's fault, as he suggested the implementation: http://stackoverflow.com/a/8793684/71522
def assert_not_in_testcase_subclass(self):

Undocumented

def param_as_nose_tuple(self, test_self, func, num, p):

Undocumented

doc_func =

Undocumented

get_input =

Undocumented