class parameterized:
Parameterize a test case:
]) def test_int(self, input, expected, base=16):
actual = int(input, base=base) assert_equal(actual, expected)
]) 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 |
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 ...> ... >>>