MCPcopy Index your code
hub / github.com/python/cpython / parameterize

Function parameterize

Lib/test/test_zipfile/_path/_test_params.py:7–25  ·  view source on GitHub ↗

Decorate a test method to run it as a set of subtests. Modeled after pytest.parametrize.

(names, value_groups)

Source from the content-addressed store, hash-verified

5
6
7def parameterize(names, value_groups):
8 """
9 Decorate a test method to run it as a set of subtests.
10
11 Modeled after pytest.parametrize.
12 """
13
14 def decorator(func):
15 @functools.wraps(func)
16 def wrapped(self):
17 for values in value_groups:
18 resolved = map(Invoked.eval, always_iterable(values))
19 params = dict(zip(always_iterable(names), resolved))
20 with self.subTest(**params):
21 func(self, **params)
22
23 return wrapped
24
25 return decorator
26
27
28class Invoked(types.SimpleNamespace):

Callers 1

test_path.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…