summaryrefslogtreecommitdiff
path: root/tests/test_util.py
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2017-07-23 20:29:42 +1000
committerDylan Araps <dylan.araps@gmail.com>2017-07-23 20:29:42 +1000
commit64e0ca26f195fb6bb2d5bda79fc402f3ac2ce9e3 (patch)
tree73ab1243a64ea96969377cad127a471492580c32 /tests/test_util.py
parenta38115407c05366c95b9008c97c8e3c276fa2562 (diff)
tests: Added test for msg()
Diffstat (limited to 'tests/test_util.py')
-rwxr-xr-xtests/test_util.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/test_util.py b/tests/test_util.py
index 01d1c9c..3a3ecdb 100755
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -1,5 +1,7 @@
"""Test util functions."""
import unittest
+import unittest.mock
+import io
import os
import pathlib
import time
@@ -95,6 +97,14 @@ class TestUtil(unittest.TestCase):
self.assertTrue(result)
os.remove(test_file)
+ def test_msg(self):
+ """> Test displaying a message."""
+ # Since this function just prints a message we redirect
+ # it's output so that we can read it.
+ with unittest.mock.patch('sys.stdout', new=io.StringIO()) as fake_out:
+ util.msg("test", True)
+ self.assertEqual(fake_out.getvalue().strip(), "test")
+
if __name__ == "__main__":
unittest.main()