MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / decorated

Function decorated

tensorflow/python/framework/test_combinations.py:247–314  ·  view source on GitHub ↗

A wrapped test method that can treat some arguments in a special way.

(self, **kwargs)

Source from the content-addressed store, hash-verified

245
246def _augment_with_special_arguments(test_method, test_combinations):
247 def decorated(self, **kwargs):
248 """A wrapped test method that can treat some arguments in a special way."""
249 original_kwargs = kwargs.copy()
250
251 # Skip combinations that are going to be executed in a different testing
252 # environment.
253 reasons_to_skip = []
254 for combination in test_combinations:
255 should_execute, reason = combination.should_execute_combination(
256 original_kwargs.copy())
257 if not should_execute:
258 reasons_to_skip.append(" - " + reason)
259
260 if reasons_to_skip:
261 self.skipTest("\n".join(reasons_to_skip))
262
263 customized_parameters = []
264 for combination in test_combinations:
265 customized_parameters.extend(combination.parameter_modifiers())
266 customized_parameters = set(customized_parameters)
267
268 # The function for running the test under the total set of
269 # `context_managers`:
270 def execute_test_method():
271 requested_parameters = tf_inspect.getfullargspec(test_method).args
272 for customized_parameter in customized_parameters:
273 for argument, value in customized_parameter.modified_arguments(
274 original_kwargs.copy(), requested_parameters).items():
275 if value is ParameterModifier.DO_NOT_PASS_TO_THE_TEST:
276 kwargs.pop(argument, None)
277 else:
278 kwargs[argument] = value
279
280 omitted_arguments = set(requested_parameters).difference(
281 set(list(kwargs.keys()) + ["self"]))
282 if omitted_arguments:
283 raise ValueError("The test requires parameters whose arguments "
284 "were not passed: {} .".format(omitted_arguments))
285 missing_arguments = set(list(kwargs.keys()) + ["self"]).difference(
286 set(requested_parameters))
287 if missing_arguments:
288 raise ValueError("The test does not take parameters that were passed "
289 ": {} .".format(missing_arguments))
290
291 kwargs_to_pass = {}
292 for parameter in requested_parameters:
293 if parameter == "self":
294 kwargs_to_pass[parameter] = self
295 else:
296 kwargs_to_pass[parameter] = kwargs[parameter]
297 test_method(**kwargs_to_pass)
298
299 # Install `context_managers` before running the test:
300 context_managers = []
301 for combination in test_combinations:
302 for manager in combination.context_managers(
303 original_kwargs.copy()):
304 context_managers.append(manager)

Callers

nothing calls this directly

Calls 9

execute_test_methodFunction · 0.85
nestedMethod · 0.80
copyMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45
extendMethod · 0.45
parameter_modifiersMethod · 0.45
context_managersMethod · 0.45

Tested by

no test coverage detected