如何解决如何在python3中统一测试日志消息?
下面是我的测试代码。我计划在其中编写多个测试用例。
from unittest import TestCase,main,mock
...
from src import method
class TestIndexingService(TestCase):
def test_start_indexing(self):
valid_files=[...]
invalid_files = [...]
with mock.patch('src.Bucket','source-bucket'):
with mock.patch('src.Key','test.json'):
with self.assertLogs() as captured:
method('opentext-archival-migration-info-dev',valid_files,queue.Queue())
self.assertEqual(captured.records[5].getMessage(),"Successfully Indexed a subset of the file: pending/2021-04-03/OPCO_194_CM-err.json")
with mock.patch('src.Bucket',invalid_files,queue.Queue())
self.assertEqual(captured.records[8].getMessage(),"Successfully Indexed a subset of the file: pending/2021-04-03/OPCO_194_CM-err.json")
但是当我运行该文件时,我只能获取第一个测试用例的日志。为什么我不能分离日志消息?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。