This repository has been archived on 2024-12-25. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2024-12-25/src/tests/test_log.py

22 lines
614 B
Python

"""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"""
with self.assertLogs('default') as cm: # pylint: disable=no-member
with proofofwork.LogOutput('+'):
subprocess.call(['echo', 'HELLO'])
self.assertEqual(cm.output, ['INFO:default:+: HELLO\n'])