Skip to content

Commit 3b36041

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 7da1166 commit 3b36041

File tree

3 files changed

+46
-30
lines changed

3 files changed

+46
-30
lines changed

src/_pytest/assertion/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,12 @@ class AssertionState:
107107
def __init__(self, config: Config, mode) -> None:
108108
self.mode = mode
109109
self.trace = config.trace.root.get("assertion")
110-
self.config=config
110+
self.config = config
111111
self.hook: rewrite.AssertionRewritingHook | None = None
112112

113113
@property
114114
def rootpath(self):
115-
"""Get current root path (current working dir)
116-
"""
115+
"""Get current root path (current working dir)"""
117116
return str(self.config.invocation_params.dir)
118117

119118

src/_pytest/pytester.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,11 +749,15 @@ def chdir(self) -> None:
749749
This is done automatically upon instantiation.
750750
"""
751751
self._monkeypatch.chdir(self.path)
752-
self._monkeypatch.setattr(self._request.config,"invocation_params", Config.InvocationParams(
753-
args= self._request.config.invocation_params.args,
752+
self._monkeypatch.setattr(
753+
self._request.config,
754+
"invocation_params",
755+
Config.InvocationParams(
756+
args=self._request.config.invocation_params.args,
754757
plugins=self._request.config.invocation_params.plugins,
755758
dir=Path(self._path),
756-
))
759+
),
760+
)
757761

758762
def _makefile(
759763
self,

testing/test_assertrewrite.py

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
from unittest import mock
2424
import zipfile
2525

26-
from mock.mock import Mock
27-
2826
import _pytest._code
2927
from _pytest._io.saferepr import DEFAULT_REPR_MAX_SIZE
3028
from _pytest.assertion import util
@@ -1308,14 +1306,18 @@ def test_rootpath_base(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> No
13081306
config = pytester.parseconfig()
13091307
state = AssertionState(config, "rewrite")
13101308
assert state.rootpath == str(config.invocation_params.dir)
1311-
new_rootpath =str(pytester.path / "test")
1309+
new_rootpath = str(pytester.path / "test")
13121310
if not os.path.exists(new_rootpath):
13131311
os.mkdir(new_rootpath)
1314-
monkeypatch.setattr(config,"invocation_params", Config.InvocationParams(
1315-
args= (),
1316-
plugins=(),
1317-
dir=Path(new_rootpath),
1318-
))
1312+
monkeypatch.setattr(
1313+
config,
1314+
"invocation_params",
1315+
Config.InvocationParams(
1316+
args=(),
1317+
plugins=(),
1318+
dir=Path(new_rootpath),
1319+
),
1320+
)
13191321
state = AssertionState(config, "rewrite")
13201322
assert state.rootpath == new_rootpath
13211323

@@ -1325,7 +1327,6 @@ def test_rootpath_base(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> No
13251327
@pytest.mark.skipif(
13261328
sys.platform.startswith("sunos5"), reason="cannot remove cwd on Solaris"
13271329
)
1328-
13291330
def test_write_pyc(self, pytester: Pytester, tmp_path) -> None:
13301331
from _pytest.assertion import AssertionState
13311332
from _pytest.assertion.rewrite import _write_pyc
@@ -2023,11 +2024,15 @@ def test_simple_failure():
20232024
rootpath = f"{os.getcwd()}/tests"
20242025
if not os.path.exists(rootpath):
20252026
mkdir(rootpath)
2026-
monkeypatch.setattr(pytester._request.config,"invocation_params", Config.InvocationParams(
2027-
args= (),
2028-
plugins=(),
2029-
dir=Path(rootpath),
2030-
))
2027+
monkeypatch.setattr(
2028+
pytester._request.config,
2029+
"invocation_params",
2030+
Config.InvocationParams(
2031+
args=(),
2032+
plugins=(),
2033+
dir=Path(rootpath),
2034+
),
2035+
)
20312036
with mock.patch.object(hook, "fnpats", ["*.py"]):
20322037
assert hook.find_spec("file") is None
20332038

@@ -2048,11 +2053,15 @@ def fix(): return 1
20482053
rootpath = f"{os.getcwd()}/tests"
20492054
if not os.path.exists(rootpath):
20502055
mkdir(rootpath)
2051-
monkeypatch.setattr(pytester._request.config,"invocation_params", Config.InvocationParams(
2052-
args= (),
2053-
plugins=(),
2054-
dir=Path(rootpath),
2055-
))
2056+
monkeypatch.setattr(
2057+
pytester._request.config,
2058+
"invocation_params",
2059+
Config.InvocationParams(
2060+
args=(),
2061+
plugins=(),
2062+
dir=Path(rootpath),
2063+
),
2064+
)
20562065
with mock.patch.object(hook, "fnpats", ["*.py"]):
20572066
assert hook.find_spec("conftest") is not None
20582067

@@ -2076,11 +2085,15 @@ def test_assert_rewrite_correct_for_plugins(
20762085
rootpath = f"{os.getcwd()}/tests"
20772086
if not os.path.exists(rootpath):
20782087
mkdir(rootpath)
2079-
monkeypatch.setattr(pytester._request.config,"invocation_params", Config.InvocationParams(
2080-
args= (),
2081-
plugins=(),
2082-
dir=Path(rootpath),
2083-
))
2088+
monkeypatch.setattr(
2089+
pytester._request.config,
2090+
"invocation_params",
2091+
Config.InvocationParams(
2092+
args=(),
2093+
plugins=(),
2094+
dir=Path(rootpath),
2095+
),
2096+
)
20842097
with mock.patch.object(hook, "fnpats", ["*.py"]):
20852098
assert hook.find_spec("plugin") is not None
20862099

0 commit comments

Comments
 (0)