diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-07-23 20:29:42 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-07-23 20:29:42 +1000 |
| commit | 64e0ca26f195fb6bb2d5bda79fc402f3ac2ce9e3 (patch) | |
| tree | 73ab1243a64ea96969377cad127a471492580c32 | |
| parent | a38115407c05366c95b9008c97c8e3c276fa2562 (diff) | |
tests: Added test for msg()
| -rwxr-xr-x | tests/test_util.py | 10 |
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() |
