Normalize whitespace in evaluate CLI output test

Depending on terminal settings, lines may be padded to the screen width
so the comparison is too strict with only the command string replacement.
This commit is contained in:
Adriane Boyd 2023-01-24 09:38:41 +01:00
parent 950fceceb6
commit f4e98812fe

View File

@ -1,4 +1,5 @@
import os
import re
from pathlib import Path
from typer.testing import CliRunner
@ -37,6 +38,8 @@ 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 result_benchmark.stdout == result_evaluate.stdout.replace(
"spacy evaluate", "spacy benchmark accuracy"
assert re.sub(r"\s+", " ", result_benchmark.stdout) == re.sub(
r"\s+",
" ",
result_evaluate.stdout.replace("spacy evaluate", "spacy benchmark accuracy"),
)