mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-08 06:04:57 +03:00
Add minimal test
This commit is contained in:
parent
5afa98aabf
commit
eb697d8371
|
@ -36,6 +36,7 @@ from spacy.training import Example, docs_to_json, offsets_to_biluo_tags
|
||||||
from spacy.training.converters import conll_ner_to_docs, conllu_to_docs
|
from spacy.training.converters import conll_ner_to_docs, conllu_to_docs
|
||||||
from spacy.training.converters import iob_to_docs
|
from spacy.training.converters import iob_to_docs
|
||||||
from spacy.util import ENV_VARS, get_minor_version, load_model_from_config, load_config
|
from spacy.util import ENV_VARS, get_minor_version, load_model_from_config, load_config
|
||||||
|
from spacy.util import run_command
|
||||||
|
|
||||||
from ..cli.init_pipeline import _init_labels
|
from ..cli.init_pipeline import _init_labels
|
||||||
from .util import make_tempdir
|
from .util import make_tempdir
|
||||||
|
@ -855,3 +856,9 @@ def test_span_length_freq_dist_output_must_be_correct():
|
||||||
span_freqs = _get_spans_length_freq_dist(sample_span_lengths, threshold)
|
span_freqs = _get_spans_length_freq_dist(sample_span_lengths, threshold)
|
||||||
assert sum(span_freqs.values()) >= threshold
|
assert sum(span_freqs.values()) >= threshold
|
||||||
assert list(span_freqs.keys()) == [3, 1, 4, 5, 2]
|
assert list(span_freqs.keys()) == [3, 1, 4, 5, 2]
|
||||||
|
|
||||||
|
|
||||||
|
def test_shell_quoting():
|
||||||
|
# simple quoted shell commands should run on any platform
|
||||||
|
ret = run_command('bash -c "echo ok"')
|
||||||
|
assert ret.returncode == 0
|
||||||
|
|
|
@ -937,12 +937,12 @@ def replace_model_node(model: Model, target: Model, replacement: Model) -> None:
|
||||||
|
|
||||||
|
|
||||||
def split_command(command: str) -> List[str]:
|
def split_command(command: str) -> List[str]:
|
||||||
"""Split a string command using shlex. Handles platform compatibility.
|
"""Split a string command using shlex.
|
||||||
|
|
||||||
command (str) : The command to split
|
command (str) : The command to split
|
||||||
RETURNS (List[str]): The split command.
|
RETURNS (List[str]): The split command.
|
||||||
"""
|
"""
|
||||||
return shlex.split(command, posix=not is_windows)
|
return shlex.split(command, posix=True)
|
||||||
|
|
||||||
|
|
||||||
def join_command(command: List[str]) -> str:
|
def join_command(command: List[str]) -> str:
|
||||||
|
@ -981,8 +981,9 @@ def run_command(
|
||||||
cmd_list = command
|
cmd_list = command
|
||||||
cmd_str = " ".join(command)
|
cmd_str = " ".join(command)
|
||||||
try:
|
try:
|
||||||
|
cmd_to_run = cmd_str if is_windows else cmd_list
|
||||||
ret = subprocess.run(
|
ret = subprocess.run(
|
||||||
cmd_list,
|
cmd_to_run,
|
||||||
env=os.environ.copy(),
|
env=os.environ.copy(),
|
||||||
input=stdin,
|
input=stdin,
|
||||||
encoding="utf8",
|
encoding="utf8",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user