File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 2
2
"""Basic tests for the CLI module."""
3
3
4
4
import os
5
+ import re
5
6
import subprocess
6
7
import sys
7
8
@@ -70,13 +71,24 @@ def test_version_show_command():
70
71
assert "101-linux v0.1.0" in result .stdout
71
72
72
73
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
+
73
85
def test_unknown_command ():
74
- """Test that an unknown command shows a helpful error."""
75
86
result = run_cli (["unknowncmd" ])
76
- assert result .returncode != 0
77
87
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
80
92
81
93
82
94
# ----------------------------
You can’t perform that action at this time.
0 commit comments