I'm trying to unit test a logging error message called in one function is displayed in another function. I have written unit test for func_a() as below, but do now know how to unit test that func_b() has called logging.error.
Example:
import logging
import unittest
In func.py
def func_a():
logging.error('error_msg')
return True
def func_b():
result = func_a()
return result
@patch('func.logging')
class Test(unittest.TestCase):
def test_func_a(self, mock_logging):
from func import func_a
mock_logging.error.assert_called_with('error_msg')
How do I write unit test for func_b() that it displays the 'error_msg'?
Appreciate any help!!