23
23
from unittest import mock
24
24
import zipfile
25
25
26
- from mock .mock import Mock
27
-
28
- from _pytest .monkeypatch import MonkeyPatch
29
-
30
26
import _pytest ._code
31
27
from _pytest ._io .saferepr import DEFAULT_REPR_MAX_SIZE
32
28
from _pytest .assertion import util
@@ -1310,14 +1306,18 @@ def test_rootpath_base(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> No
1310
1306
config = pytester .parseconfig ()
1311
1307
state = AssertionState (config , "rewrite" )
1312
1308
assert state .rootpath == str (config .invocation_params .dir )
1313
- new_rootpath = str (pytester .path / "test" )
1309
+ new_rootpath = str (pytester .path / "test" )
1314
1310
if not os .path .exists (new_rootpath ):
1315
1311
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
+ )
1321
1321
state = AssertionState (config , "rewrite" )
1322
1322
assert state .rootpath == new_rootpath
1323
1323
@@ -1327,7 +1327,6 @@ def test_rootpath_base(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> No
1327
1327
@pytest .mark .skipif (
1328
1328
sys .platform .startswith ("sunos5" ), reason = "cannot remove cwd on Solaris"
1329
1329
)
1330
-
1331
1330
def test_write_pyc (self , pytester : Pytester , tmp_path ) -> None :
1332
1331
from _pytest .assertion import AssertionState
1333
1332
from _pytest .assertion .rewrite import _write_pyc
@@ -2025,11 +2024,15 @@ def test_simple_failure():
2025
2024
rootpath = f"{ os .getcwd ()} /tests"
2026
2025
if not os .path .exists (rootpath ):
2027
2026
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
+ )
2033
2036
with mock .patch .object (hook , "fnpats" , ["*.py" ]):
2034
2037
assert hook .find_spec ("file" ) is None
2035
2038
@@ -2051,13 +2054,13 @@ def fix(): return 1
2051
2054
if not os .path .exists (rootpath ):
2052
2055
mkdir (rootpath )
2053
2056
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
+ ),
2061
2064
)
2062
2065
with mock .patch .object (hook , "fnpats" , ["*.py" ]):
2063
2066
assert hook .find_spec ("conftest" ) is not None
@@ -2083,13 +2086,13 @@ def test_assert_rewrite_correct_for_plugins(
2083
2086
if not os .path .exists (rootpath ):
2084
2087
mkdir (rootpath )
2085
2088
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
+ ),
2093
2096
)
2094
2097
with mock .patch .object (hook , "fnpats" , ["*.py" ]):
2095
2098
assert hook .find_spec ("plugin" ) is not None
0 commit comments