projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix a bug in device.py around the type of keywords, add logging and
[python_utils.git]
/
tests
/
string_utils_test.py
diff --git
a/tests/string_utils_test.py
b/tests/string_utils_test.py
index 0472daaccaf9a525794df24e79c8ae5f923898f0..51848946b68c3b661cb21d6b7d38c3eaad15e5ef 100755
(executable)
--- a/
tests/string_utils_test.py
+++ b/
tests/string_utils_test.py
@@
-2,16
+2,14
@@
import unittest
import unittest
-from ansi import fg, bg, reset
import bootstrap
import string_utils as su
import bootstrap
import string_utils as su
-
import unittest_utils as uu
import unittest_utils as uu
+from ansi import bg, fg, reset
@uu.check_all_methods_for_perf_regressions()
class TestStringUtils(unittest.TestCase):
@uu.check_all_methods_for_perf_regressions()
class TestStringUtils(unittest.TestCase):
-
def test_is_none_or_empty(self):
self.assertTrue(su.is_none_or_empty(None))
self.assertTrue(su.is_none_or_empty(""))
def test_is_none_or_empty(self):
self.assertTrue(su.is_none_or_empty(None))
self.assertTrue(su.is_none_or_empty(""))
@@
-130,7
+128,7
@@
class TestStringUtils(unittest.TestCase):
s = f' {fg("red")} this is a test {bg("white")} this is a test {reset()} '
self.assertEqual(
su.strip_escape_sequences(s),
s = f' {fg("red")} this is a test {bg("white")} this is a test {reset()} '
self.assertEqual(
su.strip_escape_sequences(s),
- ' this is a test this is a test '
+ ' this is a test this is a test '
,
)
s = ' this is another test '
self.assertEqual(su.strip_escape_sequences(s), s)
)
s = ' this is another test '
self.assertEqual(su.strip_escape_sequences(s), s)
@@
-180,6
+178,12
@@
class TestStringUtils(unittest.TestCase):
self.assertFalse(su.is_snake_case('thisIsATest'))
self.assertTrue(su.is_snake_case('this_is_a_test'))
self.assertFalse(su.is_snake_case('thisIsATest'))
self.assertTrue(su.is_snake_case('this_is_a_test'))
+ def test_sprintf_context(self):
+ with su.SprintfStdout() as buf:
+ print("This is a test.")
+ print("This is another one.")
+ self.assertEqual('This is a test.\nThis is another one.\n', buf())
+
if __name__ == '__main__':
bootstrap.initialize(unittest.main)()
if __name__ == '__main__':
bootstrap.initialize(unittest.main)()