[pre-commit.ci] pre-commit autoupdate (#10712)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 22.12.0 → 23.1.0](https://github.com/psf/black/compare/22.12.0...23.1.0) - [github.com/PyCQA/autoflake: v2.0.0 → v2.0.1](https://github.com/PyCQA/autoflake/compare/v2.0.0...v2.0.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update .pre-commit-config.yaml * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
This commit is contained in:
parent
af99040123
commit
59e7d2bbc9
|
@ -2,7 +2,7 @@ default_language_version:
|
||||||
python: "3.10"
|
python: "3.10"
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 22.12.0
|
rev: 23.1.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
args: [--safe, --quiet]
|
args: [--safe, --quiet]
|
||||||
|
@ -10,7 +10,7 @@ repos:
|
||||||
rev: 1.13.0
|
rev: 1.13.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: blacken-docs
|
- id: blacken-docs
|
||||||
additional_dependencies: [black==22.12.0]
|
additional_dependencies: [black==23.1.0]
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.4.0
|
rev: v4.4.0
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -23,7 +23,7 @@ repos:
|
||||||
exclude: _pytest/(debugging|hookspec).py
|
exclude: _pytest/(debugging|hookspec).py
|
||||||
language_version: python3
|
language_version: python3
|
||||||
- repo: https://github.com/PyCQA/autoflake
|
- repo: https://github.com/PyCQA/autoflake
|
||||||
rev: v2.0.0
|
rev: v2.0.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: autoflake
|
- id: autoflake
|
||||||
name: autoflake
|
name: autoflake
|
||||||
|
|
|
@ -1237,7 +1237,6 @@ If the data created by the factory requires managing, the fixture can take care
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def make_customer_record():
|
def make_customer_record():
|
||||||
|
|
||||||
created_records = []
|
created_records = []
|
||||||
|
|
||||||
def _make_customer_record(name):
|
def _make_customer_record(name):
|
||||||
|
|
|
@ -135,10 +135,10 @@ This can be done in our test file by defining a class to represent ``r``.
|
||||||
# this is the previous code block example
|
# this is the previous code block example
|
||||||
import app
|
import app
|
||||||
|
|
||||||
|
|
||||||
# custom class to be the mock return value
|
# custom class to be the mock return value
|
||||||
# will override the requests.Response returned from requests.get
|
# will override the requests.Response returned from requests.get
|
||||||
class MockResponse:
|
class MockResponse:
|
||||||
|
|
||||||
# mock json() method always returns a specific testing dictionary
|
# mock json() method always returns a specific testing dictionary
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def json():
|
def json():
|
||||||
|
@ -146,7 +146,6 @@ This can be done in our test file by defining a class to represent ``r``.
|
||||||
|
|
||||||
|
|
||||||
def test_get_json(monkeypatch):
|
def test_get_json(monkeypatch):
|
||||||
|
|
||||||
# Any arguments may be passed and mock_get() will always return our
|
# Any arguments may be passed and mock_get() will always return our
|
||||||
# mocked object, which only has the .json() method.
|
# mocked object, which only has the .json() method.
|
||||||
def mock_get(*args, **kwargs):
|
def mock_get(*args, **kwargs):
|
||||||
|
@ -181,6 +180,7 @@ This mock can be shared across tests using a ``fixture``:
|
||||||
# app.py that includes the get_json() function
|
# app.py that includes the get_json() function
|
||||||
import app
|
import app
|
||||||
|
|
||||||
|
|
||||||
# custom class to be the mock return value of requests.get()
|
# custom class to be the mock return value of requests.get()
|
||||||
class MockResponse:
|
class MockResponse:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -358,7 +358,6 @@ For testing purposes we can patch the ``DEFAULT_CONFIG`` dictionary to specific
|
||||||
|
|
||||||
|
|
||||||
def test_connection(monkeypatch):
|
def test_connection(monkeypatch):
|
||||||
|
|
||||||
# Patch the values of DEFAULT_CONFIG to specific
|
# Patch the values of DEFAULT_CONFIG to specific
|
||||||
# testing values only for this test.
|
# testing values only for this test.
|
||||||
monkeypatch.setitem(app.DEFAULT_CONFIG, "user", "test_user")
|
monkeypatch.setitem(app.DEFAULT_CONFIG, "user", "test_user")
|
||||||
|
@ -383,7 +382,6 @@ You can use the :py:meth:`monkeypatch.delitem <MonkeyPatch.delitem>` to remove v
|
||||||
|
|
||||||
|
|
||||||
def test_missing_user(monkeypatch):
|
def test_missing_user(monkeypatch):
|
||||||
|
|
||||||
# patch the DEFAULT_CONFIG t be missing the 'user' key
|
# patch the DEFAULT_CONFIG t be missing the 'user' key
|
||||||
monkeypatch.delitem(app.DEFAULT_CONFIG, "user", raising=False)
|
monkeypatch.delitem(app.DEFAULT_CONFIG, "user", raising=False)
|
||||||
|
|
||||||
|
@ -404,6 +402,7 @@ separate fixtures for each potential mock and reference them in the needed tests
|
||||||
# app.py with the connection string function
|
# app.py with the connection string function
|
||||||
import app
|
import app
|
||||||
|
|
||||||
|
|
||||||
# all of the mocks are moved into separated fixtures
|
# all of the mocks are moved into separated fixtures
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_test_user(monkeypatch):
|
def mock_test_user(monkeypatch):
|
||||||
|
@ -425,7 +424,6 @@ separate fixtures for each potential mock and reference them in the needed tests
|
||||||
|
|
||||||
# tests reference only the fixture mocks that are needed
|
# tests reference only the fixture mocks that are needed
|
||||||
def test_connection(mock_test_user, mock_test_database):
|
def test_connection(mock_test_user, mock_test_database):
|
||||||
|
|
||||||
expected = "User Id=test_user; Location=test_db;"
|
expected = "User Id=test_user; Location=test_db;"
|
||||||
|
|
||||||
result = app.create_connection_string()
|
result = app.create_connection_string()
|
||||||
|
@ -433,7 +431,6 @@ separate fixtures for each potential mock and reference them in the needed tests
|
||||||
|
|
||||||
|
|
||||||
def test_missing_user(mock_missing_default_user):
|
def test_missing_user(mock_missing_default_user):
|
||||||
|
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
_ = app.create_connection_string()
|
_ = app.create_connection_string()
|
||||||
|
|
||||||
|
|
|
@ -249,6 +249,7 @@ and use pytest_addoption as follows:
|
||||||
|
|
||||||
# contents of hooks.py
|
# contents of hooks.py
|
||||||
|
|
||||||
|
|
||||||
# Use firstresult=True because we only want one plugin to define this
|
# Use firstresult=True because we only want one plugin to define this
|
||||||
# default value
|
# default value
|
||||||
@hookspec(firstresult=True)
|
@hookspec(firstresult=True)
|
||||||
|
|
|
@ -274,7 +274,6 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
if sys.version_info >= (3, 10):
|
if sys.version_info >= (3, 10):
|
||||||
|
|
||||||
if sys.version_info >= (3, 12):
|
if sys.version_info >= (3, 12):
|
||||||
from importlib.resources.abc import TraversableResources
|
from importlib.resources.abc import TraversableResources
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -62,7 +62,6 @@ from _pytest.warning_types import PytestConfigWarning
|
||||||
from _pytest.warning_types import warn_explicit_for
|
from _pytest.warning_types import warn_explicit_for
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|
||||||
from _pytest._code.code import _TracebackStyle
|
from _pytest._code.code import _TracebackStyle
|
||||||
from _pytest.terminal import TerminalReporter
|
from _pytest.terminal import TerminalReporter
|
||||||
from .argparsing import Argument
|
from .argparsing import Argument
|
||||||
|
@ -1067,7 +1066,6 @@ class Config:
|
||||||
try:
|
try:
|
||||||
self.parse(args)
|
self.parse(args)
|
||||||
except UsageError:
|
except UsageError:
|
||||||
|
|
||||||
# Handle --version and --help here in a minimal fashion.
|
# Handle --version and --help here in a minimal fashion.
|
||||||
# This gets done via helpconfig normally, but its
|
# This gets done via helpconfig normally, but its
|
||||||
# pytest_cmdline_main is not called in case of errors.
|
# pytest_cmdline_main is not called in case of errors.
|
||||||
|
|
|
@ -43,7 +43,6 @@ class PathAwareHookProxy:
|
||||||
|
|
||||||
@_wraps(hook)
|
@_wraps(hook)
|
||||||
def fixed_hook(**kw):
|
def fixed_hook(**kw):
|
||||||
|
|
||||||
path_value: Optional[Path] = kw.pop(path_var, None)
|
path_value: Optional[Path] = kw.pop(path_var, None)
|
||||||
fspath_value: Optional[LEGACY_PATH] = kw.pop(fspath_var, None)
|
fspath_value: Optional[LEGACY_PATH] = kw.pop(fspath_var, None)
|
||||||
if fspath_value is not None:
|
if fspath_value is not None:
|
||||||
|
|
|
@ -531,7 +531,6 @@ class DoctestModule(Module):
|
||||||
if _is_mocked(obj):
|
if _is_mocked(obj):
|
||||||
return
|
return
|
||||||
with _patch_unwrap_mock_aware():
|
with _patch_unwrap_mock_aware():
|
||||||
|
|
||||||
# Type ignored because this is a private function.
|
# Type ignored because this is a private function.
|
||||||
super()._find( # type:ignore[misc]
|
super()._find( # type:ignore[misc]
|
||||||
tests, obj, name, module, source_lines, globs, seen
|
tests, obj, name, module, source_lines, globs, seen
|
||||||
|
|
|
@ -219,7 +219,6 @@ def _resolve_msg_to_reason(
|
||||||
"""
|
"""
|
||||||
__tracebackhide__ = True
|
__tracebackhide__ = True
|
||||||
if msg is not None:
|
if msg is not None:
|
||||||
|
|
||||||
if reason:
|
if reason:
|
||||||
from pytest import UsageError
|
from pytest import UsageError
|
||||||
|
|
||||||
|
|
|
@ -789,7 +789,8 @@ def _call_with_optional_argument(func, arg) -> None:
|
||||||
|
|
||||||
def _get_first_non_fixture_func(obj: object, names: Iterable[str]) -> Optional[object]:
|
def _get_first_non_fixture_func(obj: object, names: Iterable[str]) -> Optional[object]:
|
||||||
"""Return the attribute from the given object to be used as a setup/teardown
|
"""Return the attribute from the given object to be used as a setup/teardown
|
||||||
xunit-style function, but only if not marked as a fixture to avoid calling it twice."""
|
xunit-style function, but only if not marked as a fixture to avoid calling it twice.
|
||||||
|
"""
|
||||||
for name in names:
|
for name in names:
|
||||||
meth: Optional[object] = getattr(obj, name, None)
|
meth: Optional[object] = getattr(obj, name, None)
|
||||||
if meth is not None and fixtures.getfixturemarker(meth) is None:
|
if meth is not None and fixtures.getfixturemarker(meth) is None:
|
||||||
|
|
|
@ -572,7 +572,6 @@ def _report_kwargs_from_json(reportdict: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
and "reprcrash" in reportdict["longrepr"]
|
and "reprcrash" in reportdict["longrepr"]
|
||||||
and "reprtraceback" in reportdict["longrepr"]
|
and "reprtraceback" in reportdict["longrepr"]
|
||||||
):
|
):
|
||||||
|
|
||||||
reprtraceback = deserialize_repr_traceback(
|
reprtraceback = deserialize_repr_traceback(
|
||||||
reportdict["longrepr"]["reprtraceback"]
|
reportdict["longrepr"]["reprtraceback"]
|
||||||
)
|
)
|
||||||
|
|
|
@ -871,7 +871,6 @@ class TestDurations:
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_calls_show_2(self, pytester: Pytester, mock_timing) -> None:
|
def test_calls_show_2(self, pytester: Pytester, mock_timing) -> None:
|
||||||
|
|
||||||
pytester.makepyfile(self.source)
|
pytester.makepyfile(self.source)
|
||||||
result = pytester.runpytest_inprocess("--durations=2")
|
result = pytester.runpytest_inprocess("--durations=2")
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
|
|
|
@ -494,7 +494,6 @@ class TestLastFailed:
|
||||||
def test_lastfailed_collectfailure(
|
def test_lastfailed_collectfailure(
|
||||||
self, pytester: Pytester, monkeypatch: MonkeyPatch
|
self, pytester: Pytester, monkeypatch: MonkeyPatch
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
pytester.makepyfile(
|
pytester.makepyfile(
|
||||||
test_maybe="""
|
test_maybe="""
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -1236,7 +1236,6 @@ class TestDoctestSkips:
|
||||||
|
|
||||||
|
|
||||||
class TestDoctestAutoUseFixtures:
|
class TestDoctestAutoUseFixtures:
|
||||||
|
|
||||||
SCOPES = ["module", "session", "class", "function"]
|
SCOPES = ["module", "session", "class", "function"]
|
||||||
|
|
||||||
def test_doctest_module_session_fixture(self, pytester: Pytester):
|
def test_doctest_module_session_fixture(self, pytester: Pytester):
|
||||||
|
@ -1379,7 +1378,6 @@ class TestDoctestAutoUseFixtures:
|
||||||
|
|
||||||
|
|
||||||
class TestDoctestNamespaceFixture:
|
class TestDoctestNamespaceFixture:
|
||||||
|
|
||||||
SCOPES = ["module", "session", "class", "function"]
|
SCOPES = ["module", "session", "class", "function"]
|
||||||
|
|
||||||
@pytest.mark.parametrize("scope", SCOPES)
|
@pytest.mark.parametrize("scope", SCOPES)
|
||||||
|
|
|
@ -253,7 +253,6 @@ class TestPython:
|
||||||
duration_report: str,
|
duration_report: str,
|
||||||
run_and_parse: RunAndParse,
|
run_and_parse: RunAndParse,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
# mock LogXML.node_reporter so it always sets a known duration to each test report object
|
# mock LogXML.node_reporter so it always sets a known duration to each test report object
|
||||||
original_node_reporter = LogXML.node_reporter
|
original_node_reporter = LogXML.node_reporter
|
||||||
|
|
||||||
|
@ -603,7 +602,6 @@ class TestPython:
|
||||||
node.assert_attr(failures=3, tests=3)
|
node.assert_attr(failures=3, tests=3)
|
||||||
|
|
||||||
for index, char in enumerate("<&'"):
|
for index, char in enumerate("<&'"):
|
||||||
|
|
||||||
tnode = node.find_nth_by_tag("testcase", index)
|
tnode = node.find_nth_by_tag("testcase", index)
|
||||||
tnode.assert_attr(
|
tnode.assert_attr(
|
||||||
classname="test_failure_escape", name="test_func[%s]" % char
|
classname="test_failure_escape", name="test_func[%s]" % char
|
||||||
|
|
|
@ -906,6 +906,7 @@ def test_makereport_getsource_dynamic_code(
|
||||||
def test_store_except_info_on_error() -> None:
|
def test_store_except_info_on_error() -> None:
|
||||||
"""Test that upon test failure, the exception info is stored on
|
"""Test that upon test failure, the exception info is stored on
|
||||||
sys.last_traceback and friends."""
|
sys.last_traceback and friends."""
|
||||||
|
|
||||||
# Simulate item that might raise a specific exception, depending on `raise_error` class var
|
# Simulate item that might raise a specific exception, depending on `raise_error` class var
|
||||||
class ItemMightRaise:
|
class ItemMightRaise:
|
||||||
nodeid = "item_that_raises"
|
nodeid = "item_that_raises"
|
||||||
|
|
Loading…
Reference in New Issue