-
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure log does not contain ANSI sequences or control codes
- Loading branch information
Showing
3 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
|
||
from briefcase.console import sanitize_text | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input_text, sanitized_text", | ||
[ | ||
( | ||
"log output", | ||
"log output", | ||
), | ||
( | ||
"ls\n\x1b[00m\x1b[01;31mexamplefile.zip\x1b[00m\n\x1b[01;31m", | ||
"ls\nexamplefile.zip\n", | ||
), | ||
( | ||
"log output: \u001b[31mRed\u001B[0m", | ||
"log output: Red", | ||
), | ||
( | ||
"\u001b[1mbold log output:\u001b[0m \u001b[4mUnderline\u001b[0m", | ||
"bold log output: Underline", | ||
), | ||
( | ||
f"{chr(7)}{chr(8)}{chr(11)}{chr(12)}{chr(13)}log{chr(7)} output{chr(7)}", | ||
"log output", | ||
), | ||
], | ||
) | ||
def test_sanitize_text(input_text, sanitized_text): | ||
"""Text is sanitized as expected.""" | ||
assert sanitize_text(input_text) == sanitized_text |