Skip to content

Commit 59e7d2b

Browse files
[pre-commit.ci] pre-commit autoupdate (pytest-dev#10712)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 22.12.0 → 23.1.0](psf/black@22.12.0...23.1.0) - [github.com/PyCQA/autoflake: v2.0.0 → v2.0.1](PyCQA/autoflake@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>
1 parent af99040 commit 59e7d2b

16 files changed

+10
-24
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ default_language_version:
22
python: "3.10"
33
repos:
44
- repo: https://github.com/psf/black
5-
rev: 22.12.0
5+
rev: 23.1.0
66
hooks:
77
- id: black
88
args: [--safe, --quiet]
99
- repo: https://github.com/asottile/blacken-docs
1010
rev: 1.13.0
1111
hooks:
1212
- id: blacken-docs
13-
additional_dependencies: [black==22.12.0]
13+
additional_dependencies: [black==23.1.0]
1414
- repo: https://github.com/pre-commit/pre-commit-hooks
1515
rev: v4.4.0
1616
hooks:
@@ -23,7 +23,7 @@ repos:
2323
exclude: _pytest/(debugging|hookspec).py
2424
language_version: python3
2525
- repo: https://github.com/PyCQA/autoflake
26-
rev: v2.0.0
26+
rev: v2.0.1
2727
hooks:
2828
- id: autoflake
2929
name: autoflake

doc/en/how-to/fixtures.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,6 @@ If the data created by the factory requires managing, the fixture can take care
12371237
12381238
@pytest.fixture
12391239
def make_customer_record():
1240-
12411240
created_records = []
12421241
12431242
def _make_customer_record(name):

doc/en/how-to/monkeypatch.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,17 @@ This can be done in our test file by defining a class to represent ``r``.
135135
# this is the previous code block example
136136
import app
137137
138+
138139
# custom class to be the mock return value
139140
# will override the requests.Response returned from requests.get
140141
class MockResponse:
141-
142142
# mock json() method always returns a specific testing dictionary
143143
@staticmethod
144144
def json():
145145
return {"mock_key": "mock_response"}
146146
147147
148148
def test_get_json(monkeypatch):
149-
150149
# Any arguments may be passed and mock_get() will always return our
151150
# mocked object, which only has the .json() method.
152151
def mock_get(*args, **kwargs):
@@ -181,6 +180,7 @@ This mock can be shared across tests using a ``fixture``:
181180
# app.py that includes the get_json() function
182181
import app
183182
183+
184184
# custom class to be the mock return value of requests.get()
185185
class MockResponse:
186186
@staticmethod
@@ -358,7 +358,6 @@ For testing purposes we can patch the ``DEFAULT_CONFIG`` dictionary to specific
358358
359359
360360
def test_connection(monkeypatch):
361-
362361
# Patch the values of DEFAULT_CONFIG to specific
363362
# testing values only for this test.
364363
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
383382
384383
385384
def test_missing_user(monkeypatch):
386-
387385
# patch the DEFAULT_CONFIG t be missing the 'user' key
388386
monkeypatch.delitem(app.DEFAULT_CONFIG, "user", raising=False)
389387
@@ -404,6 +402,7 @@ separate fixtures for each potential mock and reference them in the needed tests
404402
# app.py with the connection string function
405403
import app
406404
405+
407406
# all of the mocks are moved into separated fixtures
408407
@pytest.fixture
409408
def mock_test_user(monkeypatch):
@@ -425,15 +424,13 @@ separate fixtures for each potential mock and reference them in the needed tests
425424
426425
# tests reference only the fixture mocks that are needed
427426
def test_connection(mock_test_user, mock_test_database):
428-
429427
expected = "User Id=test_user; Location=test_db;"
430428
431429
result = app.create_connection_string()
432430
assert result == expected
433431
434432
435433
def test_missing_user(mock_missing_default_user):
436-
437434
with pytest.raises(KeyError):
438435
_ = app.create_connection_string()
439436

doc/en/how-to/writing_hook_functions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ and use pytest_addoption as follows:
249249
250250
# contents of hooks.py
251251
252+
252253
# Use firstresult=True because we only want one plugin to define this
253254
# default value
254255
@hookspec(firstresult=True)

src/_pytest/assertion/rewrite.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ def get_data(self, pathname: Union[str, bytes]) -> bytes:
274274
return f.read()
275275

276276
if sys.version_info >= (3, 10):
277-
278277
if sys.version_info >= (3, 12):
279278
from importlib.resources.abc import TraversableResources
280279
else:

src/_pytest/config/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
from _pytest.warning_types import warn_explicit_for
6363

6464
if TYPE_CHECKING:
65-
6665
from _pytest._code.code import _TracebackStyle
6766
from _pytest.terminal import TerminalReporter
6867
from .argparsing import Argument
@@ -1067,7 +1066,6 @@ def pytest_cmdline_parse(
10671066
try:
10681067
self.parse(args)
10691068
except UsageError:
1070-
10711069
# Handle --version and --help here in a minimal fashion.
10721070
# This gets done via helpconfig normally, but its
10731071
# pytest_cmdline_main is not called in case of errors.

src/_pytest/config/compat.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def __getattr__(self, key, _wraps=functools.wraps):
4343

4444
@_wraps(hook)
4545
def fixed_hook(**kw):
46-
4746
path_value: Optional[Path] = kw.pop(path_var, None)
4847
fspath_value: Optional[LEGACY_PATH] = kw.pop(fspath_var, None)
4948
if fspath_value is not None:

src/_pytest/doctest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ def _find(
531531
if _is_mocked(obj):
532532
return
533533
with _patch_unwrap_mock_aware():
534-
535534
# Type ignored because this is a private function.
536535
super()._find( # type:ignore[misc]
537536
tests, obj, name, module, source_lines, globs, seen

src/_pytest/outcomes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ def _resolve_msg_to_reason(
219219
"""
220220
__tracebackhide__ = True
221221
if msg is not None:
222-
223222
if reason:
224223
from pytest import UsageError
225224

src/_pytest/python.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,8 @@ def _call_with_optional_argument(func, arg) -> None:
789789

790790
def _get_first_non_fixture_func(obj: object, names: Iterable[str]) -> Optional[object]:
791791
"""Return the attribute from the given object to be used as a setup/teardown
792-
xunit-style function, but only if not marked as a fixture to avoid calling it twice."""
792+
xunit-style function, but only if not marked as a fixture to avoid calling it twice.
793+
"""
793794
for name in names:
794795
meth: Optional[object] = getattr(obj, name, None)
795796
if meth is not None and fixtures.getfixturemarker(meth) is None:

0 commit comments

Comments
 (0)