Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parametrize_decorator_one_param():
def f():
pass
_parametrize.parametrize_decorator("abc", _parametrize.Param(1))(f)
assert f.parametrize == [_parametrize.Param(1, arg_names=("abc",))]
def test_parametrize_decorator_multiple_and_stack():
def f():
pass
_parametrize.parametrize_decorator("abc, def", [(1, "a"), (2, "b")])(f)
_parametrize.parametrize_decorator("foo", ["bar", "baz"])(f)
assert f.parametrize == [
{"abc": 1, "def": "a", "foo": "bar"},
{"abc": 2, "def": "b", "foo": "bar"},
{"abc": 1, "def": "a", "foo": "baz"},
{"abc": 2, "def": "b", "foo": "baz"},
]
def test_parametrize_decorator_one_with_args():
def f():
pass
_parametrize.parametrize_decorator("abc", [1, 2, 3])(f)
assert f.parametrize == [{"abc": 1}, {"abc": 2}, {"abc": 3}]
def test_parametrize_decorator_stack():
def f():
pass
_parametrize.parametrize_decorator("abc", [1, 2, 3])(f)
_parametrize.parametrize_decorator("def", ["a", "b"])(f)
assert f.parametrize == [
{"abc": 1, "def": "a"},
{"abc": 2, "def": "a"},
{"abc": 3, "def": "a"},
{"abc": 1, "def": "b"},
{"abc": 2, "def": "b"},
{"abc": 3, "def": "b"},
]
def test_parametrize_decorator_one():
def f():
pass
_parametrize.parametrize_decorator("abc", 1)(f)
assert f.parametrize == [_parametrize.Param(1, arg_names=("abc",))]
def test_parametrize_decorator_mixed_params():
def f():
pass
_parametrize.parametrize_decorator(
"abc, def", [(1, 2), _parametrize.Param(3, 4, id="b"), _parametrize.Param(5, 6)]
)(f)
arg_names = ("abc", "def")
assert f.parametrize == [
_parametrize.Param(1, 2, arg_names=arg_names),
_parametrize.Param(3, 4, arg_names=arg_names, id="b"),
_parametrize.Param(5, 6, arg_names=arg_names),
]
def test_parametrize_decorator_multiple_and_stack():
def f():
pass
_parametrize.parametrize_decorator("abc, def", [(1, "a"), (2, "b")])(f)
_parametrize.parametrize_decorator("foo", ["bar", "baz"])(f)
assert f.parametrize == [
{"abc": 1, "def": "a", "foo": "bar"},
{"abc": 2, "def": "b", "foo": "bar"},
{"abc": 1, "def": "a", "foo": "baz"},
{"abc": 2, "def": "b", "foo": "baz"},
]
def test_parametrize_decorator_multiple_args_as_list():
def f():
pass
_parametrize.parametrize_decorator(["abc", "def"], [("a", 1), ("b", 2), ("c", 3)])(
f
)
assert f.parametrize == [
{"abc": "a", "def": 1},
{"abc": "b", "def": 2},
{"abc": "c", "def": 3},
]