diff options
| author | Scott <[email protected]> | 2022-01-27 13:42:09 -0800 |
|---|---|---|
| committer | Scott <[email protected]> | 2022-01-27 13:42:09 -0800 |
| commit | b3ef553f4f30614b97e23f2d4ad6d6576ec57adf (patch) | |
| tree | a8ad1d0d07d6ba439b020581360f896ad1a737ea /tests/exec_utils_test.py | |
| parent | c901f3eb1acf78fd4933d8faeedc517ccafe627e (diff) | |
Adding test code trying to improve test coverage.
Diffstat (limited to 'tests/exec_utils_test.py')
| -rwxr-xr-x | tests/exec_utils_test.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/exec_utils_test.py b/tests/exec_utils_test.py new file mode 100755 index 0000000..eb179da --- /dev/null +++ b/tests/exec_utils_test.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +import unittest + +import exec_utils +import unittest_utils + + +class TestExecUtils(unittest.TestCase): + def test_cmd_showing_output(self): + with unittest_utils.RecordStdout() as record: + ret = exec_utils.cmd_showing_output('/usr/bin/printf hello') + self.assertEqual('hello', record().readline()) + self.assertEqual(0, ret) + record().close() + + def test_cmd_showing_output_fails(self): + with unittest_utils.RecordStdout() as record: + ret = exec_utils.cmd_showing_output('/usr/bin/printf hello && false') + self.assertEqual('hello', record().readline()) + self.assertEqual(1, ret) + record().close() + + def test_cmd_in_background(self): + p = exec_utils.cmd_in_background('sleep 100') + self.assertEqual(None, p.poll()) + + +if __name__ == '__main__': + unittest.main() |
