diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 5bbd0d957..412591991 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1645,7 +1645,7 @@ class Config: elif type == "bool": return _strtobool(str(value).strip()) elif type == "int": - return int(value) + return int(str(value).strip()) elif type == "string": return value elif type is None: diff --git a/src/_pytest/config/argparsing.py b/src/_pytest/config/argparsing.py index b39519e6c..ebb3693c2 100644 --- a/src/_pytest/config/argparsing.py +++ b/src/_pytest/config/argparsing.py @@ -215,7 +215,16 @@ class Parser: The value of ini-variables can be retrieved via a call to :py:func:`config.getini(name) `. """ - assert type in (None, "string", "paths", "pathlist", "args", "linelist", "bool", "int") + assert type in ( + None, + "string", + "paths", + "pathlist", + "args", + "linelist", + "bool", + "int", + ) if default is NOT_SET: default = get_ini_default_for_type(type) @@ -224,7 +233,9 @@ class Parser: def get_ini_default_for_type( - type: Optional[Literal["string", "paths", "pathlist", "args", "linelist", "bool", "int"]], + type: Optional[ + Literal["string", "paths", "pathlist", "args", "linelist", "bool", "int"] + ], ) -> Any: """ Used by addini to get the default value for a given ini-option type, when diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 3220a936e..5e92f3adb 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -846,11 +846,20 @@ class LoggingPlugin: @hookimpl(wrapper=True) def pytest_runtest_setup(self, item: nodes.Item) -> Generator[None, None, None]: - if self.log_file_verbose and int(self.log_file_verbose) >= 1: old_log_file_formatter = self.log_file_handler.formatter self.log_file_handler.setFormatter(logging.Formatter()) - self.log_file_handler.emit(logging.LogRecord('N/A', logging.INFO, 'N/A', 0, f"Running at {item.nodeid}", None, None)) + self.log_file_handler.emit( + logging.LogRecord( + "N/A", + logging.INFO, + "N/A", + 0, + f"Running at {item.nodeid}", + None, + None, + ) + ) self.log_file_handler.setFormatter(old_log_file_formatter) self.log_cli_handler.set_when("setup") diff --git a/testing/local_testing/add_function.py b/testing/local_testing/add_function.py index 40bd7ec64..e1829c359 100644 --- a/testing/local_testing/add_function.py +++ b/testing/local_testing/add_function.py @@ -1,3 +1,2 @@ -def add(a, b): +def add(a: int, b: int) -> int: return a + b - diff --git a/testing/local_testing/local_test_0.py b/testing/local_testing/local_test_0.py index 95dbd553c..fbc477f15 100644 --- a/testing/local_testing/local_test_0.py +++ b/testing/local_testing/local_test_0.py @@ -1,16 +1,16 @@ import pytest + @pytest.mark.parametrize("arg1, arg2", [(1, 1)]) -def test_parametrization(arg1, arg2): +def test_parametrization(arg1: int, arg2: int) -> None: assert arg1 == arg2 assert arg1 + 1 == arg2 + 1 # Gets the error: In test_parametrization: indirect fixture '(1, 1)' doesn't exist -# Goal is to change this message into a more beginner friendly message. - +# Goal is to change this message into a more beginner friendly message. + # The error message lives in this path: pytest/src/_pytest/python.py - -#("arg1", "arg2"), and "arg1, arg2" works, but cannot put in default parameters as normal function \ No newline at end of file +# ("arg1", "arg2"), and "arg1, arg2" works, but cannot put in default parameters as normal function diff --git a/testing/local_testing/local_test_test.py b/testing/local_testing/local_test_test.py index a677697bf..968eff81e 100644 --- a/testing/local_testing/local_test_test.py +++ b/testing/local_testing/local_test_test.py @@ -1,22 +1,13 @@ # test_math_operations.py -import pytest import add_function +import pytest + + +result_index = [(1, 2, 3), (-1, 1, 0), (0, 0, 0), (5, -3, 2), (1, 1, 2)] -result_index = [ - (1, 2, 3), - (-1, 1, 0), - (0, 0, 0), - (5, -3, 2), - (1, 1, 2) -] @pytest.mark.parametrize("a, b, expected_result", result_index) - - -def test_add(a, b, expected_result): +def test_add(a: int, b: int, expected_result: int) -> None: assert add_function.add(a, b) == expected_result - - -