Skip to content

Commit eceae2e

Browse files
pre-commit-ci[bot]Tusenka
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 48cfbc3 commit eceae2e

File tree

10 files changed

+28
-12
lines changed

10 files changed

+28
-12
lines changed

src/_pytest/assertion/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __init__(self, config: Config, mode) -> None:
114114
self.hook: rewrite.AssertionRewritingHook | None = None
115115

116116
@property
117-
def invocation_path( self ):
117+
def invocation_path(self):
118118
"""Get current root path (current working dir)"""
119119
return str(self.config.invocation_params.dir)
120120

src/_pytest/assertion/rewrite.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ def _should_rewrite(self, name: str, fn: str, state: AssertionState) -> bool:
239239
# rewritten if they match the naming convention for test files
240240
fn_path = PurePath(fn)
241241
for pat in self.fnpats:
242-
if fnmatch_ex(pat, fn_path) and fn_path.is_relative_to( state.invocation_path ):
242+
if fnmatch_ex(pat, fn_path) and fn_path.is_relative_to(
243+
state.invocation_path
244+
):
243245
state.trace(f"matched test file {fn!r}")
244246
return True
245247

src/_pytest/helpconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def pytest_addoption(parser: Parser) -> None:
8787
help="Trace considerations of conftest.py files",
8888
)
8989
group.addoption(
90-
"--debug",
90+
"--debug",
9191
action="store",
9292
nargs="?",
9393
const="pytestdebug.log",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[pytest]
2-
python_files = *.py
2+
python_files = *.py
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
from __future__ import annotations
2+
13
import pytest
24

5+
36
@pytest.fixture
47
def special_asserter():
58
def special_assert(x, y):
6-
assert {'x': x} == {'x': y}
7-
return special_assert
9+
assert {"x": x} == {"x": y}
10+
11+
return special_assert
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
from __future__ import annotations
2+
3+
14
def func(x: int, y: int):
2-
assert x>0
3-
assert y>0
4-
return 0 if x == y else 1 if x>y else -1
5+
assert x > 0
6+
assert y > 0
7+
return 0 if x == y else 1 if x > y else -1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
from __future__ import annotations
2+
13
from _pytest.fixtures import fixture
24

5+
36
pytest_plugins = ["pytester", "some_plugin"]
47

58

69
@fixture
710
def b():
811
return 1
912

13+
1014
@fixture
1115
def a():
1216
return 2
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from typing import Callable
24

35
from testing.example_scripts.rewrite.src.main import func
@@ -6,5 +8,6 @@
68
def test_plugin(a: int, b: int, special_asserter: Callable[[int, int], bool]):
79
special_asserter(a, b)
810

11+
912
def test_func(a: int, b: int, special_asserter: Callable[[int, int], bool]):
10-
assert {'res': func(a, b)} == {'res': 0}
13+
assert {"res": func(a, b)} == {"res": 0}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
def some_check(a: int):
22
assert abs(a)<2
3-
return a in set(0, 1, -1)
3+
return a in set(0, 1, -1)

testing/test_assertrewrite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ def test_invocation_dir(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> N
13031303

13041304
config = pytester.parseconfig()
13051305
state = AssertionState(config, "rewrite")
1306-
assert state.invocation_path == str( config.invocation_params.dir )
1306+
assert state.invocation_path == str(config.invocation_params.dir)
13071307
new_rootpath = str(pytester.path / "test")
13081308
if not os.path.exists(new_rootpath):
13091309
os.mkdir(new_rootpath)

0 commit comments

Comments
 (0)