mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-27 23:45:01 +03:00
Switch to use TemporaryDirectory
This commit is contained in:
parent
c8b7912bf6
commit
786473d827
|
@ -1,5 +1,7 @@
|
|||
import os
|
||||
from time import time
|
||||
from tempfile import TemporaryDirectory
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
import srsly
|
||||
from spacy.cli._util import load_project_config
|
||||
|
@ -218,8 +220,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."""
|
||||
try:
|
||||
with make_tempdir() as d:
|
||||
with TemporaryDirectory(ignore_cleanup_errors=True) as d: # avoid errors in Windows CI
|
||||
dirpath = Path(d)
|
||||
|
||||
pscript = """
|
||||
import sys
|
||||
|
@ -256,11 +258,11 @@ sys.exit(int(rc))
|
|||
]
|
||||
},
|
||||
}
|
||||
srsly.write_yaml(d / "project.yml", project)
|
||||
load_project_config(d)
|
||||
srsly.write_yaml(dirpath / "project.yml", project)
|
||||
load_project_config(dirpath)
|
||||
start = time()
|
||||
with pytest.raises(SystemExit) as rc_e:
|
||||
project_run(d, "all")
|
||||
project_run(dirpath, "all")
|
||||
if os.name == "nt":
|
||||
# because in Windows the terminated process has rc=15 rather than rc=-15,
|
||||
# 15 is the highest rc rather than 1.
|
||||
|
@ -271,6 +273,3 @@ sys.exit(int(rc))
|
|||
assert (
|
||||
time_taken < 15
|
||||
), "Test took {time_taken}, subprocess seems not to have been terminated"
|
||||
except PermissionError: # occurs on Windows in the CI because the terminated subprocess still has
|
||||
# a handle on the temporary directory
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue
Block a user