mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Merged revisions 70975 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r70975 | brett.cannon | 2009-04-01 12:57:10 -0700 (Wed, 01 Apr 2009) | 4 lines test_logging was blindly clearing the warnings filter. This caused PendingDeprecationWarnings to be spewed all over by unittest.failIf*(). Fix moves over to using warnings.catch_warning to protect the warnings filter. ........
This commit is contained in:
parent
3f10a952f6
commit
df8709d7b1
1 changed files with 23 additions and 21 deletions
|
@ -910,8 +910,10 @@ class EncodingTest(BaseTest):
|
|||
|
||||
|
||||
class WarningsTest(BaseTest):
|
||||
|
||||
def test_warnings(self):
|
||||
logging.captureWarnings(True)
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings("always", category=UserWarning)
|
||||
try:
|
||||
file = io.StringIO()
|
||||
|
@ -926,13 +928,13 @@ class WarningsTest(BaseTest):
|
|||
|
||||
#See if an explicit file uses the original implementation
|
||||
file = io.StringIO()
|
||||
warnings.showwarning("Explicit", UserWarning, "dummy.py", 42, file,
|
||||
"Dummy line")
|
||||
warnings.showwarning("Explicit", UserWarning, "dummy.py", 42,
|
||||
file, "Dummy line")
|
||||
s = file.getvalue()
|
||||
file.close()
|
||||
self.assertEqual(s, "dummy.py:42: UserWarning: Explicit\n Dummy line\n")
|
||||
self.assertEqual(s,
|
||||
"dummy.py:42: UserWarning: Explicit\n Dummy line\n")
|
||||
finally:
|
||||
warnings.resetwarnings()
|
||||
logging.captureWarnings(False)
|
||||
|
||||
# Set the locale to the platform-dependent default. I have no idea
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue