mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-02 11:20:19 +03:00
Move to test util method
This commit is contained in:
parent
f4e98812fe
commit
431465befc
|
@ -1,10 +1,9 @@
|
|||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from spacy.cli._util import app
|
||||
from .util import make_tempdir
|
||||
from .util import make_tempdir, assert_strings_equal_except_ws
|
||||
|
||||
|
||||
def test_convert_auto():
|
||||
|
@ -38,8 +37,7 @@ def test_benchmark_accuracy_alias():
|
|||
# Verify that the `evaluate` alias works correctly.
|
||||
result_benchmark = CliRunner().invoke(app, ["benchmark", "accuracy", "--help"])
|
||||
result_evaluate = CliRunner().invoke(app, ["evaluate", "--help"])
|
||||
assert re.sub(r"\s+", " ", result_benchmark.stdout) == re.sub(
|
||||
r"\s+",
|
||||
" ",
|
||||
assert_strings_equal_except_ws(
|
||||
result_benchmark.stdout,
|
||||
result_evaluate.stdout.replace("spacy evaluate", "spacy benchmark accuracy"),
|
||||
)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import numpy
|
||||
import tempfile
|
||||
import contextlib
|
||||
import re
|
||||
import srsly
|
||||
from spacy.tokens import Doc
|
||||
from spacy.vocab import Vocab
|
||||
|
@ -95,3 +96,8 @@ def assert_packed_msg_equal(b1, b2):
|
|||
for (k1, v1), (k2, v2) in zip(sorted(msg1.items()), sorted(msg2.items())):
|
||||
assert k1 == k2
|
||||
assert v1 == v2
|
||||
|
||||
|
||||
def assert_strings_equal_except_ws(s1, s2):
|
||||
"""Assert that two strings are identical except for whitespace."""
|
||||
assert re.sub(r"\s+", " ", s1) == re.sub(r"\s+", " ", s2)
|
||||
|
|
Loading…
Reference in New Issue
Block a user