MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / parameterize

Function parameterize

test/decorators.py:632–647  ·  view source on GitHub ↗

Add additional parameterization to a test function. This function create or adds to the `_parameterize` property of a function which is then expanded by the RunnerMeta metaclass into multiple separate test functions.

(func, parameters)

Source from the content-addressed store, hash-verified

630
631
632def parameterize(func, parameters):
633 """Add additional parameterization to a test function.
634
635 This function create or adds to the `_parameterize` property of a function
636 which is then expanded by the RunnerMeta metaclass into multiple separate
637 test functions.
638 """
639 prev = getattr(func, '_parameterize', None)
640 assert not any(p.startswith('_') for p in parameters), 'test variant names should not start with _'
641 if prev:
642 # If we're parameterizing 2nd time, construct a cartesian product for various combinations.
643 func._parameterize = {
644 '_'.join(filter(None, [k1, k2])): v2 + v1 for (k1, v1), (k2, v2) in itertools.product(prev.items(), parameters.items())
645 }
646 else:
647 func._parameterize = parameters
648
649
650def parameterized(parameters):

Callers 15

also_with_llvm_libcFunction · 0.90
with_both_compilersFunction · 0.90
wasmfs_all_backendsFunction · 0.90
with_dylink_reversedFunction · 0.90
with_asyncify_and_jspiFunction · 0.90
also_with_wasm_workersFunction · 0.90
with_both_text_decoderFunction · 0.90
also_with_pthreadsFunction · 0.85
also_with_wasmfsFunction · 0.85
also_with_nodefsFunction · 0.85

Calls 2

getattrFunction · 0.50
joinMethod · 0.45

Tested by 8

also_with_llvm_libcFunction · 0.72
with_both_compilersFunction · 0.72
wasmfs_all_backendsFunction · 0.72
with_dylink_reversedFunction · 0.72
with_asyncify_and_jspiFunction · 0.72
also_with_wasm_workersFunction · 0.72
with_both_text_decoderFunction · 0.72