Skip to content

Commit 651f7e0

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent db7dcd4 commit 651f7e0

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/_pytest/assertion/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def __init__(self, config: Config, mode) -> None:
112112
@property
113113
def rootpath(self):
114114
"""
115-
get current root path (current working dir)
115+
Get current root path (current working dir)
116116
"""
117117
try:
118118
return os.getcwd()

testing/test_assertrewrite.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from typing import cast
2323
from unittest import mock
2424
import zipfile
25+
2526
from mock.mock import Mock
2627

2728
import _pytest._code
@@ -1282,12 +1283,12 @@ def test_meta_path():
12821283
)
12831284
assert pytester.runpytest().ret == 0
12841285

1285-
12861286
def test_rootpath_base(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
12871287
"""
12881288
Base cases for get rootpath from AssertionState
12891289
"""
12901290
from _pytest.assertion import AssertionState
1291+
12911292
config = pytester.parseconfig()
12921293
monkeypatch.chdir(pytester.path)
12931294
state = AssertionState(config, "rewrite")
@@ -1299,23 +1300,26 @@ def test_rootpath_base(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> No
12991300
state = AssertionState(config, "rewrite")
13001301
assert state.rootpath == new_rootpath
13011302

1302-
13031303
@pytest.mark.skipif(
13041304
sys.platform.startswith("win32"), reason="cannot remove cwd on Windows"
13051305
)
13061306
@pytest.mark.skipif(
13071307
sys.platform.startswith("sunos5"), reason="cannot remove cwd on Solaris"
13081308
)
1309-
def test_rootpath_cwd_removed(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
1309+
def test_rootpath_cwd_removed(
1310+
self, pytester: Pytester, monkeypatch: MonkeyPatch
1311+
) -> None:
13101312
# Setup conditions for py's trying to os.getcwd() on py34
13111313
# when current working directory doesn't exist (previously triggered via xdist only).
13121314
# Ref: https://github.com/pytest-dev/py/pull/207
13131315
from _pytest.assertion import AssertionState
1316+
13141317
config = pytester.parseconfig()
1315-
monkeypatch.setattr(target=os, name="getcwd", value=Mock(side_effect=FileNotFoundError))
1318+
monkeypatch.setattr(
1319+
target=os, name="getcwd", value=Mock(side_effect=FileNotFoundError)
1320+
)
13161321
state = AssertionState(config, "rewrite")
1317-
assert state.rootpath == os.path.abspath(os.sep)
1318-
1322+
assert state.rootpath == os.path.abspath(os.sep)
13191323

13201324
def test_write_pyc(self, pytester: Pytester, tmp_path) -> None:
13211325
from _pytest.assertion import AssertionState
@@ -1920,6 +1924,7 @@ def hook(
19201924
if PathFinder.find_spec has been called.
19211925
"""
19221926
import importlib.machinery
1927+
19231928
self.find_spec_calls: list[str] = []
19241929
self.initial_paths: set[Path] = set()
19251930

@@ -1993,7 +1998,6 @@ def test_simple_failure():
19931998
assert hook.find_spec("file") is not None
19941999
assert self.find_spec_calls == ["file"]
19952000

1996-
19972001
def test_assert_rewrites_only_rootpath(
19982002
self, pytester: Pytester, hook: AssertionRewritingHook, monkeypatch
19992003
) -> None:
@@ -2013,12 +2017,11 @@ def test_simple_failure():
20132017

20142018
rootpath = f"{os.getcwd()}/tests"
20152019
if not os.path.exists(rootpath):
2016-
mkdir(rootpath)
2020+
mkdir(rootpath)
20172021
monkeypatch.chdir(rootpath)
20182022
with mock.patch.object(hook, "fnpats", ["*.py"]):
20192023
assert hook.find_spec("file") is None
20202024

2021-
20222025
def test_assert_rewrite_correct_for_conftfest(
20232026
self, pytester: Pytester, hook: AssertionRewritingHook, monkeypatch
20242027
) -> None:
@@ -2035,12 +2038,11 @@ def fix(): return 1
20352038

20362039
rootpath = f"{os.getcwd()}/tests"
20372040
if not os.path.exists(rootpath):
2038-
mkdir(rootpath)
2041+
mkdir(rootpath)
20392042
monkeypatch.chdir(rootpath)
20402043

20412044
with mock.patch.object(hook, "fnpats", ["*.py"]):
20422045
assert hook.find_spec("conftest") is not None
2043-
20442046

20452047
def test_assert_rewrite_correct_for_plugins(
20462048
self, pytester: Pytester, hook: AssertionRewritingHook, monkeypatch
@@ -2061,12 +2063,11 @@ def test_assert_rewrite_correct_for_plugins(
20612063
hook.mark_rewrite("plugin")
20622064
rootpath = f"{os.getcwd()}/tests"
20632065
if not os.path.exists(rootpath):
2064-
mkdir(rootpath)
2066+
mkdir(rootpath)
20652067
monkeypatch.chdir(rootpath)
20662068
with mock.patch.object(hook, "fnpats", ["*.py"]):
20672069
assert hook.find_spec("plugin") is not None
20682070

2069-
20702071
@pytest.mark.skipif(
20712072
sys.platform.startswith("win32"), reason="cannot remove cwd on Windows"
20722073
)

0 commit comments

Comments
 (0)