Add a separate logging test case with a test for proofofwork.LogOutput()

This commit is contained in:
Dmitri Bogomolov 2021-07-26 20:07:31 +03:00
parent 174dffb360
commit f4f78a1011
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

21
src/tests/test_log.py Normal file
View File

@ -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