diff --git a/src/tests/test_log.py b/src/tests/test_log.py new file mode 100644 index 00000000..e62010a0 --- /dev/null +++ b/src/tests/test_log.py @@ -0,0 +1,21 @@ +"""Tests for logging""" + +import subprocess +import sys +import unittest + +from pybitmessage import proofofwork + + +class TestLog(unittest.TestCase): + """A test case for logging""" + + @unittest.skipIf( + sys.hexversion < 0x3000000, 'assertLogs is new in version 3.4') + def test_LogOutput(self): + """Use proofofwork.LogOutput to log output of a shell command""" + def echo(): + """Call the echo shell command""" + with proofofwork.LogOutput(): + subprocess.call(['echo', 'HELLO']) + self.assertLogs(echo(), 'HELLO') # pylint: disable=no-member