Skip to content

Commit c947f9a

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 e7a98bb commit c947f9a

File tree

3 files changed

+42
-36
lines changed

3 files changed

+42
-36
lines changed

src/_pytest/assertion/__init__.py

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

117117
@property
118118
def rootpath(self):
119-
"""Get current root path (current working dir)
120-
"""
119+
"""Get current root path (current working dir)"""
121120
return str(self.config.invocation_params.dir)
122121

123122

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: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
from unittest import mock
2424
import zipfile
2525

26-
from mock.mock import Mock
27-
28-
from _pytest.monkeypatch import MonkeyPatch
29-
3026
import _pytest._code
3127
from _pytest._io.saferepr import DEFAULT_REPR_MAX_SIZE
3228
from _pytest.assertion import util
@@ -1310,14 +1306,18 @@ def test_rootpath_base(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> No
13101306
config = pytester.parseconfig()
13111307
state = AssertionState(config, "rewrite")
13121308
assert state.rootpath == str(config.invocation_params.dir)
1313-
new_rootpath =str(pytester.path / "test")
1309+
new_rootpath = str(pytester.path / "test")
13141310
if not os.path.exists(new_rootpath):
13151311
os.mkdir(new_rootpath)
1316-
monkeypatch.setattr(config,"invocation_params", Config.InvocationParams(
1317-
args= (),
1318-
plugins=(),
1319-
dir=Path(new_rootpath),
1320-
))
1312+
monkeypatch.setattr(
1313+
config,
1314+
"invocation_params",
1315+
Config.InvocationParams(
1316+
args=(),
1317+
plugins=(),
1318+
dir=Path(new_rootpath),
1319+
),
1320+
)
13211321
state = AssertionState(config, "rewrite")
13221322
assert state.rootpath == new_rootpath
13231323

@@ -1327,7 +1327,6 @@ def test_rootpath_base(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> No
13271327
@pytest.mark.skipif(
13281328
sys.platform.startswith("sunos5"), reason="cannot remove cwd on Solaris"
13291329
)
1330-
13311330
def test_write_pyc(self, pytester: Pytester, tmp_path) -> None:
13321331
from _pytest.assertion import AssertionState
13331332
from _pytest.assertion.rewrite import _write_pyc
@@ -2025,11 +2024,15 @@ def test_simple_failure():
20252024
rootpath = f"{os.getcwd()}/tests"
20262025
if not os.path.exists(rootpath):
20272026
mkdir(rootpath)
2028-
monkeypatch.setattr(pytester._request.config,"invocation_params", Config.InvocationParams(
2029-
args= (),
2030-
plugins=(),
2031-
dir=Path(rootpath),
2032-
))
2027+
monkeypatch.setattr(
2028+
pytester._request.config,
2029+
"invocation_params",
2030+
Config.InvocationParams(
2031+
args=(),
2032+
plugins=(),
2033+
dir=Path(rootpath),
2034+
),
2035+
)
20332036
with mock.patch.object(hook, "fnpats", ["*.py"]):
20342037
assert hook.find_spec("file") is None
20352038

@@ -2051,13 +2054,13 @@ def fix(): return 1
20512054
if not os.path.exists(rootpath):
20522055
mkdir(rootpath)
20532056
monkeypatch.setattr(
2054-
pytester._request.config,
2055-
"invocation_params",
2056-
Config.InvocationParams(
2057-
args= (),
2058-
plugins=(),
2059-
dir=Path(rootpath),
2060-
)
2057+
pytester._request.config,
2058+
"invocation_params",
2059+
Config.InvocationParams(
2060+
args=(),
2061+
plugins=(),
2062+
dir=Path(rootpath),
2063+
),
20612064
)
20622065
with mock.patch.object(hook, "fnpats", ["*.py"]):
20632066
assert hook.find_spec("conftest") is not None
@@ -2083,13 +2086,13 @@ def test_assert_rewrite_correct_for_plugins(
20832086
if not os.path.exists(rootpath):
20842087
mkdir(rootpath)
20852088
monkeypatch.setattr(
2086-
pytester._request.config,
2087-
"invocation_params",
2088-
Config.InvocationParams(
2089-
args= (),
2090-
plugins=(),
2091-
dir=Path(rootpath),
2092-
)
2089+
pytester._request.config,
2090+
"invocation_params",
2091+
Config.InvocationParams(
2092+
args=(),
2093+
plugins=(),
2094+
dir=Path(rootpath),
2095+
),
20932096
)
20942097
with mock.patch.object(hook, "fnpats", ["*.py"]):
20952098
assert hook.find_spec("plugin") is not None

0 commit comments

Comments
 (0)