Skip to content

Commit b3804bb

Browse files
abhas20bobbyiliev
authored andcommitted
updated the test
1 parent ad0bbd9 commit b3804bb

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

cli/test_cli.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Basic tests for the CLI module."""
33

44
import os
5+
import re
56
import subprocess
67
import sys
78

@@ -70,13 +71,24 @@ def test_version_show_command():
7071
assert "101-linux v0.1.0" in result.stdout
7172

7273

74+
ANSI_ESCAPE = re.compile(r"\x1B\[[0-?]*[ -/]*[@-~]")
75+
EMOJI = re.compile("[\U0001f300-\U0001faff]", flags=re.UNICODE)
76+
77+
78+
def clean_output(text: str) -> str:
79+
"""Remove ANSI colors and emojis."""
80+
text = ANSI_ESCAPE.sub("", text)
81+
text = EMOJI.sub("", text)
82+
return text
83+
84+
7385
def test_unknown_command():
74-
"""Test that an unknown command shows a helpful error."""
7586
result = run_cli(["unknowncmd"])
76-
assert result.returncode != 0
7787
combined_output = result.stdout + result.stderr
78-
assert "No such command" in combined_output
79-
assert "Hint: Run 'cli.py --help' to see available commands." in combined_output
88+
clean = clean_output(combined_output)
89+
90+
assert "No such command" in clean
91+
assert "Hint: Run 'cli.py --help' to see available commands." in clean
8092

8193

8294
# ----------------------------

0 commit comments

Comments
 (0)