run test suite on the implementation
This commit is contained in:
parent
ea6ddbc870
commit
66d9e3b364
|
@ -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:
|
||||
|
|
|
@ -215,7 +215,16 @@ class Parser:
|
|||
The value of ini-variables can be retrieved via a call to
|
||||
:py:func:`config.getini(name) <pytest.Config.getini>`.
|
||||
"""
|
||||
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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
def add(a, b):
|
||||
def add(a: int, b: int) -> int:
|
||||
return a + b
|
||||
|
||||
|
|
|
@ -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
|
||||
# ("arg1", "arg2"), and "arg1, arg2" works, but cannot put in default parameters as normal function
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue