From 8dca42846d2956122d45795763095559a6a51b64 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sun, 9 Apr 2023 21:15:18 +0100 Subject: Migrate code style to ruff Co-authored-by: Boris Muratov <8bee278@gmail.com> Co-authored-by: wookie184 --- tests/test_base.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'tests/test_base.py') diff --git a/tests/test_base.py b/tests/test_base.py index 365805a71..f1fb1a514 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -30,15 +30,19 @@ class LoggingTestCaseTests(unittest.TestCase): r"1 logs of DEBUG or higher were triggered on root:\n" r'' ) - with self.assertRaisesRegex(AssertionError, msg_regex): - with LoggingTestCase.assertNotLogs(self, level=logging.DEBUG): - self.log.debug("Log!") + with ( + self.assertRaisesRegex(AssertionError, msg_regex), + LoggingTestCase.assertNotLogs(self, level=logging.DEBUG), + ): + self.log.debug("Log!") def test_assert_not_logs_reraises_unexpected_exception_in_managed_context(self): """Test if LoggingTestCase.assertNotLogs reraises an unexpected exception.""" - with self.assertRaises(ValueError, msg="test exception"): - with LoggingTestCase.assertNotLogs(self, level=logging.DEBUG): - raise ValueError("test exception") + with ( + self.assertRaises(ValueError, msg="test exception"), + LoggingTestCase.assertNotLogs(self, level=logging.DEBUG), + ): + raise ValueError("test exception") def test_assert_not_logs_restores_old_logging_settings(self): """Test if LoggingTestCase.assertNotLogs reraises an unexpected exception.""" @@ -56,9 +60,8 @@ class LoggingTestCaseTests(unittest.TestCase): def test_logging_test_case_works_with_logger_instance(self): """Test if the LoggingTestCase captures logging for provided logger.""" log = get_logger("new_logger") - with self.assertRaises(AssertionError): - with LoggingTestCase.assertNotLogs(self, logger=log): - log.info("Hello, this should raise an AssertionError") + with self.assertRaises(AssertionError), LoggingTestCase.assertNotLogs(self, logger=log): + log.info("Hello, this should raise an AssertionError") def test_logging_test_case_respects_alternative_logger(self): """Test if LoggingTestCase only checks the provided logger.""" -- cgit v1.2.3