forked from alan-turing-institute/data-safe-haven
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request alan-turing-institute#2231 from alan-turing-instit…
…ute/ansi_logfile Remove ANSI escape sequences from logfile
- Loading branch information
Showing
2 changed files
with
20 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
import pytest | ||
|
||
from data_safe_haven.logging.plain_file_handler import PlainFileHandler | ||
|
||
|
||
class TestPlainFileHandler: | ||
def test_strip_formatting(self): | ||
assert PlainFileHandler.strip_formatting("[green]hello[/]") == "hello" | ||
def test_strip_rich_formatting(self): | ||
assert PlainFileHandler.strip_rich_formatting("[green]Hello[/]") == "Hello" | ||
|
||
@pytest.mark.parametrize("escape", ["\033", "\x1B", "\u001b", "\x1B"]) | ||
def test_strip_ansi_escapes(self, escape): | ||
assert ( | ||
PlainFileHandler.strip_ansi_escapes(f"{escape}[31;1;4mHello{escape}[0m") | ||
== "Hello" | ||
) |