How to use the nox._parametrize.Param function in nox

To help you get started, we’ve selected a few nox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github theacodes / nox / tests / test__parametrize.py View on Github external
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),
    ]
github theacodes / nox / tests / test__parametrize.py View on Github external
        (_parametrize.Param(1, 3), _parametrize.Param(1, 2), False),
        (_parametrize.Param(1, 2, arg_names=("a", "b")), {"a": 1, "b": 2}, True),
    ],
)
def test_param_eq(param, other, expected):
    assert (param == other) is expected
github theacodes / nox / tests / test__parametrize.py View on Github external
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),
    ]
github theacodes / nox / tests / test__parametrize.py View on Github external
def test_generate_calls_multiple_args():

    f = mock.Mock()
    f.__name__ = "f"

    arg_names = ("abc", "foo")
    call_specs = [
        _parametrize.Param(1, "a", arg_names=arg_names),
        _parametrize.Param(2, "b", arg_names=arg_names),
        _parametrize.Param(3, "c", arg_names=arg_names),
    ]

    calls = _parametrize.generate_calls(f, call_specs)

    assert len(calls) == 3
    assert calls[0].session_signature == "(abc=1, foo='a')"
    assert calls[1].session_signature == "(abc=2, foo='b')"
    assert calls[2].session_signature == "(abc=3, foo='c')"

    calls[0]()
    f.assert_called_with(abc=1, foo="a")
    calls[1]()
    f.assert_called_with(abc=2, foo="b")
    calls[2]()
github theacodes / nox / tests / test__parametrize.py View on Github external
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),
    ]
github theacodes / nox / tests / test__parametrize.py View on Github external
def test_generate_calls_simple():

    f = mock.Mock()
    f.__name__ = "f"
    f.some_prop = 42

    arg_names = ("abc",)
    call_specs = [
        _parametrize.Param(1, arg_names=arg_names),
        _parametrize.Param(2, arg_names=arg_names),
        _parametrize.Param(3, arg_names=arg_names),
    ]

    calls = _parametrize.generate_calls(f, call_specs)

    assert len(calls) == 3
    assert calls[0].session_signature == "(abc=1)"
    assert calls[1].session_signature == "(abc=2)"
    assert calls[2].session_signature == "(abc=3)"

    calls[0]()
    f.assert_called_with(abc=1)
    calls[1]()
    f.assert_called_with(abc=2)
    calls[2]()
    f.assert_called_with(abc=3)
github theacodes / nox / tests / test__parametrize.py View on Github external
def test_generate_calls_simple():

    f = mock.Mock()
    f.__name__ = "f"
    f.some_prop = 42

    arg_names = ("abc",)
    call_specs = [
        _parametrize.Param(1, arg_names=arg_names),
        _parametrize.Param(2, arg_names=arg_names),
        _parametrize.Param(3, arg_names=arg_names),
    ]

    calls = _parametrize.generate_calls(f, call_specs)

    assert len(calls) == 3
    assert calls[0].session_signature == "(abc=1)"
    assert calls[1].session_signature == "(abc=2)"
    assert calls[2].session_signature == "(abc=3)"

    calls[0]()
    f.assert_called_with(abc=1)
    calls[1]()
    f.assert_called_with(abc=2)
    calls[2]()
    f.assert_called_with(abc=3)
github theacodes / nox / tests / test__parametrize.py View on Github external
def test_generate_calls_multiple_args():

    f = mock.Mock()
    f.__name__ = "f"

    arg_names = ("abc", "foo")
    call_specs = [
        _parametrize.Param(1, "a", arg_names=arg_names),
        _parametrize.Param(2, "b", arg_names=arg_names),
        _parametrize.Param(3, "c", arg_names=arg_names),
    ]

    calls = _parametrize.generate_calls(f, call_specs)

    assert len(calls) == 3
    assert calls[0].session_signature == "(abc=1, foo='a')"
    assert calls[1].session_signature == "(abc=2, foo='b')"
    assert calls[2].session_signature == "(abc=3, foo='c')"

    calls[0]()
    f.assert_called_with(abc=1, foo="a")
    calls[1]()
    f.assert_called_with(abc=2, foo="b")
    calls[2]()
    f.assert_called_with(abc=3, foo="c")
github theacodes / nox / nox / _parametrize.py View on Github external
for n, value in enumerate(arg_values_list):
            if not isinstance(value, Param):
                arg_values_list[n] = [value]

    # if ids aren't specified at all, make them an empty list for zip.
    if not ids:
        ids = []

    # Generate params for each item in the param_args_values list.
    param_specs = []
    for param_arg_values, param_id in itertools.zip_longest(arg_values_list, ids):
        if isinstance(param_arg_values, Param):
            param_spec = param_arg_values
            param_spec.arg_names = tuple(arg_names)
        else:
            param_spec = Param(*param_arg_values, arg_names=arg_names, id=param_id)

        param_specs.append(param_spec)

    return functools.partial(_apply_param_specs, param_specs)