mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-10 08:12:24 +03:00
Add debug config test and restructure
The code argument imports the provided file. If it adds item to the registry, that affects global state, which CliRunner doesn't isolate. Since there's no standard way to remove things from the registry, this instead uses subprocess.run to run commands.
This commit is contained in:
parent
5cddb4e320
commit
6d594b966c
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import pytest
|
import pytest
|
||||||
|
import subprocess
|
||||||
from typer.testing import CliRunner
|
from typer.testing import CliRunner
|
||||||
|
|
||||||
import spacy
|
import spacy
|
||||||
|
@ -199,14 +200,47 @@ def noop_config():
|
||||||
yield cfg
|
yield cfg
|
||||||
|
|
||||||
|
|
||||||
def test_multi_code_debug_data(code_paths, data_paths, noop_config):
|
def test_multi_code_debug_config(code_paths, data_paths, noop_config):
|
||||||
# check that it fails without the code arg
|
# check that it fails without the code arg
|
||||||
result = CliRunner().invoke(app, ["debug", "data", str(noop_config), *data_paths])
|
result = subprocess.run(
|
||||||
assert result.exit_code == 1
|
["python", "-m", "spacy", "debug", "config", str(noop_config), *data_paths]
|
||||||
|
)
|
||||||
|
assert result.returncode == 1
|
||||||
|
|
||||||
# check that it succeeds with the code arg
|
# check that it succeeds with the code arg
|
||||||
code_arg = ["--code", ",".join([str(pp) for pp in code_paths])]
|
result = subprocess.run(
|
||||||
result = CliRunner().invoke(
|
[
|
||||||
app, ["debug", "data", str(noop_config), *data_paths, *code_paths]
|
"python",
|
||||||
|
"-m",
|
||||||
|
"spacy",
|
||||||
|
"debug",
|
||||||
|
"config",
|
||||||
|
str(noop_config),
|
||||||
|
*data_paths,
|
||||||
|
*code_paths,
|
||||||
|
]
|
||||||
)
|
)
|
||||||
assert result.exit_code == 0
|
assert result.returncode == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_multi_code_debug_data(code_paths, data_paths, noop_config):
|
||||||
|
# check that it fails without the code arg
|
||||||
|
result = subprocess.run(
|
||||||
|
["python", "-m", "spacy", "debug", "data", str(noop_config), *data_paths]
|
||||||
|
)
|
||||||
|
assert result.returncode == 1
|
||||||
|
|
||||||
|
# check that it succeeds with the code arg
|
||||||
|
result = subprocess.run(
|
||||||
|
[
|
||||||
|
"python",
|
||||||
|
"-m",
|
||||||
|
"spacy",
|
||||||
|
"debug",
|
||||||
|
"data",
|
||||||
|
str(noop_config),
|
||||||
|
*data_paths,
|
||||||
|
*code_paths,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
assert result.returncode == 0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user