class documentation

class parameterized: (source)

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 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.
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 assert_not_in_testcase_subclass Undocumented
Method param_as_nose_tuple Undocumented
Instance Variable doc_func Undocumented
Instance Variable get_input Undocumented
Method _terrible_magic_get_defining_classes 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: ...
@classmethod
def check_input_values(cls, input_values): (source)

Undocumented

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

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): (source)

Undocumented

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

Undocumented

@classmethod
def to_safe_name(cls, s): (source)

Undocumented

def __call__(self, test_func): (source)

Undocumented

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

Undocumented

def assert_not_in_testcase_subclass(self): (source)

Undocumented

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

Undocumented

doc_func = (source)

Undocumented

get_input = (source)

Undocumented

def _terrible_magic_get_defining_classes(self): (source)

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