aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_base.py
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2023-04-09 21:15:18 +0100
committerGravatar Chris Lovering <[email protected]>2023-04-11 16:48:14 +0100
commit8dca42846d2956122d45795763095559a6a51b64 (patch)
tree480cd7d3c1a6d6bc87710e2d3c19f223a92f7c5d /tests/test_base.py
parentReplace CI flake8 config with ruff (diff)
Migrate code style to ruff
Co-authored-by: Boris Muratov <[email protected]> Co-authored-by: wookie184 <[email protected]>
Diffstat (limited to 'tests/test_base.py')
-rw-r--r--tests/test_base.py21
1 files changed, 12 insertions, 9 deletions
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'<LogRecord: tests\.test_base, [\d]+, .+[/\\]tests[/\\]test_base\.py, [\d]+, "Log!">'
)
- 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."""