class documentation
class parameterized: (source)
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 |
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 |
Undocumented |
Class Method | param |
Undocumented |
Class Method | to |
Undocumented |
Method | __call__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | assert |
Undocumented |
Method | param |
Undocumented |
Instance Variable | doc |
Undocumented |
Instance Variable | get |
Undocumented |
Method | _terrible |
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: ... |
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 ...> ... >>>
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