Below is my test code. In it i planed to write multiple test cases.
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', 'source-bucket'):
with mock.patch('src.Key', 'test.json'):
with self.assertLogs() as captured:
method('opentext-archival-migration-info-dev', 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")
But when i run the file i only get the logs for first testcase. Why i can't separate log messages?