Python testing: How can I verify that no error logs were thrown? - Stack Overflow

admin2025-04-18  9

In my test I want to verify that no error log was done during the test. How do I do that?

I tried with self.assertLogs("", level="ERROR") as error_logs:. This can capture the error logs, but it will also raise if there were no error logs at all.

In my test I want to verify that no error log was done during the test. How do I do that?

I tried with self.assertLogs("", level="ERROR") as error_logs:. This can capture the error logs, but it will also raise if there were no error logs at all.

Share Improve this question asked Jan 30 at 1:45 DarkTrickDarkTrick 3,5553 gold badges30 silver badges54 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

with self.assertNoLogs("", level="ERROR")

reference: https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertNoLogs

转载请注明原文地址:http://anycun.com/QandA/1744942383a89808.html