Change to normalization method

This commit is contained in:
Adriane Boyd 2023-01-27 15:11:48 +01:00
parent 431465befc
commit 8c3df5f372
2 changed files with 5 additions and 7 deletions

View File

@ -3,7 +3,7 @@ from pathlib import Path
from typer.testing import CliRunner from typer.testing import CliRunner
from spacy.cli._util import app from spacy.cli._util import app
from .util import make_tempdir, assert_strings_equal_except_ws from .util import make_tempdir, normalize_whitespace
def test_convert_auto(): def test_convert_auto():
@ -37,7 +37,6 @@ def test_benchmark_accuracy_alias():
# Verify that the `evaluate` alias works correctly. # Verify that the `evaluate` alias works correctly.
result_benchmark = CliRunner().invoke(app, ["benchmark", "accuracy", "--help"]) result_benchmark = CliRunner().invoke(app, ["benchmark", "accuracy", "--help"])
result_evaluate = CliRunner().invoke(app, ["evaluate", "--help"]) result_evaluate = CliRunner().invoke(app, ["evaluate", "--help"])
assert_strings_equal_except_ws( assert normalize_whitespace(result_benchmark.stdout) == normalize_whitespace(
result_benchmark.stdout, result_evaluate.stdout.replace("spacy evaluate", "spacy benchmark accuracy")
result_evaluate.stdout.replace("spacy evaluate", "spacy benchmark accuracy"),
) )

View File

@ -98,6 +98,5 @@ def assert_packed_msg_equal(b1, b2):
assert v1 == v2 assert v1 == v2
def assert_strings_equal_except_ws(s1, s2): def normalize_whitespace(s):
"""Assert that two strings are identical except for whitespace.""" return re.sub(r"\s+", " ", s)
assert re.sub(r"\s+", " ", s1) == re.sub(r"\s+", " ", s2)