mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-06 21:30:22 +03:00
Use mkdtemp()
This commit is contained in:
parent
b8a299f349
commit
2cc2cc1a15
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import shutil
|
||||
from time import time
|
||||
from tempfile import TemporaryDirectory
|
||||
from tempfile import mkdtemp
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
import srsly
|
||||
|
@ -220,9 +221,8 @@ def test_project_run_multiprocessing_failure(failing_command: str):
|
|||
with a non-zero return code, the other two commands after several seconds with
|
||||
zero return codes. Measuring the execution length for the whole group shows
|
||||
whether or not the sleeping processes were successfully terminated."""
|
||||
with TemporaryDirectory(ignore_cleanup_errors=True) as d: # avoid errors in Windows CI
|
||||
d = mkdtemp() # avoid errors in Windows CI that occur with make_tempdir()
|
||||
dirpath = Path(d)
|
||||
|
||||
pscript = """
|
||||
import sys
|
||||
from time import sleep
|
||||
|
@ -232,7 +232,7 @@ sleep(int(sleep_secs))
|
|||
sys.exit(int(rc))
|
||||
"""
|
||||
|
||||
pscript_loc = os.sep.join((str(d), "pscript.py"))
|
||||
pscript_loc = os.sep.join((d, "pscript.py"))
|
||||
with open(pscript_loc, "w") as pscript_file:
|
||||
pscript_file.write(pscript)
|
||||
os.chmod(pscript_loc, 0o777)
|
||||
|
@ -273,3 +273,7 @@ sys.exit(int(rc))
|
|||
assert (
|
||||
time_taken < 15
|
||||
), "Test took {time_taken}, subprocess seems not to have been terminated"
|
||||
try:
|
||||
shutil.rmtree(d)
|
||||
except: # sometimes fails in Windows CI owing to CI-specific race condition
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue
Block a user