From f74f6a87a384cf36381d020a39762e1abaab915d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 31 Oct 2021 13:25:30 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- changelog/9074.improvement.rst | 2 +- src/_pytest/python.py | 10 +++++++--- testing/test_mark.py | 19 +++++++++---------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/changelog/9074.improvement.rst b/changelog/9074.improvement.rst index 21f18905b..c7b10f81e 100644 --- a/changelog/9074.improvement.rst +++ b/changelog/9074.improvement.rst @@ -14,4 +14,4 @@ For example, now such a construction is possible:: ) -Earlier in this case the values ``a, b, c`` in test are a ``ParameterSet`` objects \ No newline at end of file +Earlier in this case the values ``a, b, c`` in test are a ``ParameterSet`` objects diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 73ba4cfa1..47d4ef3f6 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1140,7 +1140,9 @@ class Metafunc: normalized_values.append(*param_value.values) if param_value.marks: merged_marks.append(*param_value.marks) - param_set = ParameterSet(values=tuple(normalized_values), marks=merged_marks, id=None) + param_set = ParameterSet( + values=tuple(normalized_values), marks=merged_marks, id=None + ) newcallspec = callspec.setmulti( valtypes=arg_values_types, argnames=argnames, @@ -1404,8 +1406,10 @@ def _idvalset( if val.id: this_id.append(val.id) continue - to_get_idval = (val.values[0] if len(val.values) == 1 else val.values) - this_id.append(_idval(to_get_idval, argname, idx, idfn, nodeid=nodeid, config=config)) + to_get_idval = val.values[0] if len(val.values) == 1 else val.values + this_id.append( + _idval(to_get_idval, argname, idx, idfn, nodeid=nodeid, config=config) + ) return "-".join(this_id) else: return _ascii_escaped_by_config(id, config) diff --git a/testing/test_mark.py b/testing/test_mark.py index 70ac81bc6..4df6043ce 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -1,7 +1,10 @@ import os import sys -from typing import List, NamedTuple, Tuple, Any +from typing import Any +from typing import List +from typing import NamedTuple from typing import Optional +from typing import Tuple from unittest import mock import pytest @@ -355,14 +358,10 @@ def test_parametrize_with_nested_paramsets( pytester: Pytester, pytester_internal_test_values: List[Any] ) -> None: """Test parametrize with nested pytest.param objects in value""" - case = NamedTuple( - "case", - [ - ("expected_test_id", str), - ("expected_value", Tuple[Any, ...]), - ("expected_marks", Tuple[str, ...]), - ], - ) + class case(NamedTuple): + expected_test_id: str + expected_value: Tuple[Any, ...] + expected_marks: Tuple[str, ...] cases = ( case("1-nested_2-3", (1, 2, 3), ("parametrize",)), case("one_two_three", (1, 2, 3), ("parametrize",)), @@ -383,7 +382,7 @@ def test_parametrize_with_nested_paramsets( """ import pytest @pytest.mark.parametrize( - "a, b, c", + "a, b, c", [ (1, pytest.param(2, id="nested_2"), pytest.param(3)), pytest.param(1, pytest.param(2, id="nested_2"), pytest.param(3), id="one_two_three"),