Skip to content

Commit

Permalink
tests: Add strip_console_codes test
Browse files Browse the repository at this point in the history
Signed-off-by: Lukáš Doktor <[email protected]>
  • Loading branch information
ldoktor committed Aug 19, 2024
1 parent 33fd20e commit 0a99d55
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat Inc. 2024
# Author: Lukas Doktor <[email protected]>

# selftests pylint: disable=C0111,C0111

import unittest

from aexpect.utils import astring


class Astring(unittest.TestCase):

def test_strip_console_codes(self):
"""
Try various strip_console_codes
"""
strip = astring.strip_console_codes
self.assertEqual("simple color test",
strip("simple\x1b[33;1m color \x1b[0mtest"))
self.assertEqual("[33;1mstarts with code", "[33;1mstarts with code")
self.assertEqual("ends with escape\x1b", "ends with escape\x1b")


if __name__ == '__main__':
unittest.main()

0 comments on commit 0a99d55

Please sign in to comment.