The decorator to be returned.
(test_method_or_class)
| 199 | ValueError: if any parameters were not accepted by the test method |
| 200 | """ |
| 201 | def decorator(test_method_or_class): |
| 202 | """The decorator to be returned.""" |
| 203 | |
| 204 | # Generate good test names that can be used with --test_filter. |
| 205 | named_combinations = [] |
| 206 | for combination in combinations: |
| 207 | # We use OrderedDicts in `combine()` and `times()` to ensure stable |
| 208 | # order of keys in each dictionary. |
| 209 | assert isinstance(combination, OrderedDict) |
| 210 | name = "".join([ |
| 211 | "_{}_{}".format("".join(filter(str.isalnum, key)), |
| 212 | "".join(filter(str.isalnum, _get_name(value, i)))) |
| 213 | for i, (key, value) in enumerate(combination.items()) |
| 214 | ]) |
| 215 | named_combinations.append( |
| 216 | OrderedDict( |
| 217 | list(combination.items()) + |
| 218 | [("testcase_name", "_test{}".format(name))])) |
| 219 | |
| 220 | if isinstance(test_method_or_class, type): |
| 221 | class_object = test_method_or_class |
| 222 | class_object._test_method_ids = test_method_ids = {} |
| 223 | for name, test_method in six.iteritems(class_object.__dict__.copy()): |
| 224 | if (name.startswith(unittest.TestLoader.testMethodPrefix) and |
| 225 | isinstance(test_method, types.FunctionType)): |
| 226 | delattr(class_object, name) |
| 227 | methods = {} |
| 228 | parameterized._update_class_dict_for_param_test_case( |
| 229 | class_object.__name__, methods, test_method_ids, name, |
| 230 | parameterized._ParameterizedTestIter( |
| 231 | _augment_with_special_arguments( |
| 232 | test_method, test_combinations=test_combinations), |
| 233 | named_combinations, parameterized._NAMED, name)) |
| 234 | for method_name, method in six.iteritems(methods): |
| 235 | setattr(class_object, method_name, method) |
| 236 | |
| 237 | return class_object |
| 238 | else: |
| 239 | test_method = _augment_with_special_arguments( |
| 240 | test_method_or_class, test_combinations=test_combinations) |
| 241 | return parameterized.named_parameters(*named_combinations)(test_method) |
| 242 | |
| 243 | return decorator |
| 244 |
nothing calls this directly
no test coverage detected