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

Skip to content

Commit 7633d23

Browse files
committed
Don't call warnings.resetwarnings(); that does bad things that cause
other tests to generate warning when they didn't before. In particular, this cancels not only filters set by -W, but also from test.regrtest.
1 parent 154c088 commit 7633d23

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Lib/test/test_tempfile.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
import unittest
1111
from test import test_support
1212

13+
warnings.filterwarnings("ignore",
14+
category=RuntimeWarning,
15+
message="mktemp", module=__name__)
16+
1317
if hasattr(os, 'stat'):
1418
import stat
1519
has_stat = 1
@@ -478,16 +482,11 @@ class test_mktemp(TC):
478482
# We must also suppress the RuntimeWarning it generates.
479483
def setUp(self):
480484
self.dir = tempfile.mkdtemp()
481-
warnings.filterwarnings("ignore",
482-
category=RuntimeWarning,
483-
message="mktemp")
484485

485486
def tearDown(self):
486487
if self.dir:
487488
os.rmdir(self.dir)
488489
self.dir = None
489-
# XXX This clobbers any -W options.
490-
warnings.resetwarnings()
491490

492491
class mktemped:
493492
_unlink = os.unlink

0 commit comments

Comments
 (0)