From 8baf2d6a57f0b3952d1b8749c9b1919eb8bf2be8 Mon Sep 17 00:00:00 2001 From: Liz Gehret Date: Thu, 17 Oct 2024 11:49:24 -0600 Subject: [PATCH 1/3] BUG: log output formatting not as expected --- rescript/tests/test_ncbi.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rescript/tests/test_ncbi.py b/rescript/tests/test_ncbi.py index eb91395..00ebc0f 100644 --- a/rescript/tests/test_ncbi.py +++ b/rescript/tests/test_ncbi.py @@ -237,6 +237,7 @@ def test_ncbi_fails(self): 'k__Fungi; p__Basidiomycota; c__Agaricomycetes; ' 'o__Boletales; f__Boletaceae; g__Boletus; s__edulis' ) + raise ValueError(log.output) self.assertTrue('Retrying' in '\n'.join(log.output[:3])) def test_get_ncbi_dirty_tricks(self): From a52890e9c9bb7d11179fd22da4fdbd4dce0fe0ef Mon Sep 17 00:00:00 2001 From: Liz Gehret Date: Thu, 17 Oct 2024 13:26:36 -0600 Subject: [PATCH 2/3] improve flexibility of assertion for log output --- rescript/tests/test_ncbi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rescript/tests/test_ncbi.py b/rescript/tests/test_ncbi.py index 00ebc0f..d0e2260 100644 --- a/rescript/tests/test_ncbi.py +++ b/rescript/tests/test_ncbi.py @@ -237,8 +237,8 @@ def test_ncbi_fails(self): 'k__Fungi; p__Basidiomycota; c__Agaricomycetes; ' 'o__Boletales; f__Boletaceae; g__Boletus; s__edulis' ) - raise ValueError(log.output) - self.assertTrue('Retrying' in '\n'.join(log.output[:3])) + exp_log_segment = 'Retrying' + self.assertTrue(exp_log_segment in line for line in log.output) def test_get_ncbi_dirty_tricks(self): with self.assertLogs(level='WARNING') as log: From 6c1fca3c14f42849de0030a384192364ebecde92 Mon Sep 17 00:00:00 2001 From: Liz Gehret Date: Thu, 17 Oct 2024 15:01:23 -0600 Subject: [PATCH 3/3] better approach --- rescript/tests/test_ncbi.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rescript/tests/test_ncbi.py b/rescript/tests/test_ncbi.py index d0e2260..fc9821c 100644 --- a/rescript/tests/test_ncbi.py +++ b/rescript/tests/test_ncbi.py @@ -238,7 +238,16 @@ def test_ncbi_fails(self): 'o__Boletales; f__Boletaceae; g__Boletus; s__edulis' ) exp_log_segment = 'Retrying' - self.assertTrue(exp_log_segment in line for line in log.output) + for line in log.output: + if exp_log_segment in line: + result = True + break + else: + result = False + self.assertTrue( + result, + f'`{exp_log_segment}` not found in the output log.' + ) def test_get_ncbi_dirty_tricks(self): with self.assertLogs(level='WARNING') as log: