Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 750eae1

Browse files
Issue #24678: Fixed raiseExceptions typo in logging tests.
Patch by Jacek Kołodziej.
1 parent 19c1a87 commit 750eae1

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

Lib/test/test_logging.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
import tempfile
4242
from test.script_helper import assert_python_ok
4343
from test.support import (captured_stdout, run_with_locale, run_unittest,
44-
patch, requires_zlib, TestHandler, Matcher, HOST)
44+
patch, requires_zlib, TestHandler, Matcher, HOST,
45+
swap_attr)
4546
import textwrap
4647
import time
4748
import unittest
@@ -3748,18 +3749,12 @@ def test_exception(self):
37483749
(exc.__class__, exc, exc.__traceback__))
37493750

37503751
def test_log_invalid_level_with_raise(self):
3751-
old_raise = logging.raiseExceptions
3752-
self.addCleanup(setattr, logging, 'raiseExecptions', old_raise)
3753-
3754-
logging.raiseExceptions = True
3755-
self.assertRaises(TypeError, self.logger.log, '10', 'test message')
3752+
with swap_attr(logging, 'raiseExceptions', True):
3753+
self.assertRaises(TypeError, self.logger.log, '10', 'test message')
37563754

37573755
def test_log_invalid_level_no_raise(self):
3758-
old_raise = logging.raiseExceptions
3759-
self.addCleanup(setattr, logging, 'raiseExecptions', old_raise)
3760-
3761-
logging.raiseExceptions = False
3762-
self.logger.log('10', 'test message') # no exception happens
3756+
with swap_attr(logging, 'raiseExceptions', False):
3757+
self.logger.log('10', 'test message') # no exception happens
37633758

37643759
def test_find_caller_with_stack_info(self):
37653760
called = []

0 commit comments

Comments
 (0)