33
33
from _pytest .assertion .util import ( # noqa: F401
34
34
format_explanation as _format_explanation ,
35
35
)
36
- from _pytest .compat import fspath
37
36
from _pytest .config import Config
38
37
from _pytest .main import Session
39
38
from _pytest .pathlib import fnmatch_ex
@@ -306,7 +305,7 @@ def _write_pyc(
306
305
pyc : Path ,
307
306
) -> bool :
308
307
try :
309
- with atomic_write (fspath (pyc ), mode = "wb" , overwrite = True ) as fp :
308
+ with atomic_write (os . fspath (pyc ), mode = "wb" , overwrite = True ) as fp :
310
309
_write_pyc_fp (fp , source_stat , co )
311
310
except OSError as e :
312
311
state .trace ("error writing pyc file at {}: {}" .format (pyc , e ))
@@ -336,7 +335,7 @@ def _write_pyc(
336
335
337
336
try :
338
337
_write_pyc_fp (fp , source_stat , co )
339
- os .rename (proc_pyc , fspath (pyc ))
338
+ os .rename (proc_pyc , os . fspath (pyc ))
340
339
except OSError as e :
341
340
state .trace ("error writing pyc file at {}: {}" .format (pyc , e ))
342
341
# we ignore any failure to write the cache file
@@ -350,7 +349,7 @@ def _write_pyc(
350
349
351
350
def _rewrite_test (fn : Path , config : Config ) -> Tuple [os .stat_result , types .CodeType ]:
352
351
"""Read and rewrite *fn* and return the code object."""
353
- fn_ = fspath (fn )
352
+ fn_ = os . fspath (fn )
354
353
stat = os .stat (fn_ )
355
354
with open (fn_ , "rb" ) as f :
356
355
source = f .read ()
@@ -368,12 +367,12 @@ def _read_pyc(
368
367
Return rewritten code if successful or None if not.
369
368
"""
370
369
try :
371
- fp = open (fspath (pyc ), "rb" )
370
+ fp = open (os . fspath (pyc ), "rb" )
372
371
except OSError :
373
372
return None
374
373
with fp :
375
374
try :
376
- stat_result = os .stat (fspath (source ))
375
+ stat_result = os .stat (os . fspath (source ))
377
376
mtime = int (stat_result .st_mtime )
378
377
size = stat_result .st_size
379
378
data = fp .read (12 )
@@ -831,7 +830,7 @@ def visit_Assert(self, assert_: ast.Assert) -> List[ast.stmt]:
831
830
"assertion is always true, perhaps remove parentheses?"
832
831
),
833
832
category = None ,
834
- filename = fspath (self .module_path ),
833
+ filename = os . fspath (self .module_path ),
835
834
lineno = assert_ .lineno ,
836
835
)
837
836
@@ -1072,7 +1071,7 @@ def try_makedirs(cache_dir: Path) -> bool:
1072
1071
Returns True if successful or if it already exists.
1073
1072
"""
1074
1073
try :
1075
- os .makedirs (fspath (cache_dir ), exist_ok = True )
1074
+ os .makedirs (os . fspath (cache_dir ), exist_ok = True )
1076
1075
except (FileNotFoundError , NotADirectoryError , FileExistsError ):
1077
1076
# One of the path components was not a directory:
1078
1077
# - we're in a zip file
0 commit comments