From f4e98812fee914b58db4d87bf40bfa049218d868 Mon Sep 17 00:00:00 2001 From: Adriane Boyd Date: Tue, 24 Jan 2023 09:38:41 +0100 Subject: [PATCH] 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. --- spacy/tests/test_cli_app.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spacy/tests/test_cli_app.py b/spacy/tests/test_cli_app.py index 84b2b8d4d..5f1ce81f0 100644 --- a/spacy/tests/test_cli_app.py +++ b/spacy/tests/test_cli_app.py @@ -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"), )