Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 9, 2024
1 parent 2d991b5 commit 3405966
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
from _pytest.scope import _ScopeName
from _pytest.scope import Scope
from _pytest.stash import StashKey
from _pytest.warning_types import PytestCollectionWarning, PytestDefaultArgumentWarning, warn_explicit_for
from _pytest.warning_types import PytestCollectionWarning
from _pytest.warning_types import PytestDefaultArgumentWarning


if TYPE_CHECKING:
Expand Down Expand Up @@ -145,12 +146,18 @@ def async_fail(nodeid: str) -> None:

def async_default_arg_warn(nodeid: str, function_name, param) -> None:
msg = (

Check warning on line 148 in src/_pytest/python.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/python.py#L148

Added line #L148 was not covered by tests
"Test function '" + function_name + "' has a default argument '" + param.name + "=" + str(param.default) + "'.\n"
"Test function '"
+ function_name
+ "' has a default argument '"
+ param.name
+ "="
+ str(param.default)
+ "'.\n"
)
warnings.simplefilter("always", PytestDefaultArgumentWarning)
warnings.warn(PytestDefaultArgumentWarning(msg))

Check warning on line 158 in src/_pytest/python.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/python.py#L157-L158

Added lines #L157 - L158 were not covered by tests


@hookimpl(trylast=True)
def pytest_pyfunc_call(pyfuncitem: Function) -> object | None:
testfunction = pyfuncitem.obj
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/warning_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PytestCollectionWarning(PytestWarning):
@final
class PytestDefaultArgumentWarning(PytestWarning):
"""Warning emitted when a test function has default arguments."""

__module__ = "pytest"


Expand Down

0 comments on commit 3405966

Please sign in to comment.