bpo-32089: Use default action for ResourceWarning (#4584)

In development and debug mode, use the "default" action, rather than
the "always" action, for ResourceWarning in the default warnings
filters.
This commit is contained in:
Victor Stinner 2017-11-27 12:11:55 +01:00 committed by GitHub
parent c172fc5031
commit 21c7730761
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 21 deletions

View file

@ -532,26 +532,26 @@ class CmdLineTest(unittest.TestCase):
out = self.run_xdev("-c", code)
self.assertEqual(out,
"ignore::BytesWarning "
"always::ResourceWarning "
"default::ResourceWarning "
"default::Warning")
out = self.run_xdev("-b", "-c", code)
self.assertEqual(out,
"default::BytesWarning "
"always::ResourceWarning "
"default::ResourceWarning "
"default::Warning")
out = self.run_xdev("-bb", "-c", code)
self.assertEqual(out,
"error::BytesWarning "
"always::ResourceWarning "
"default::ResourceWarning "
"default::Warning")
out = self.run_xdev("-Werror", "-c", code)
self.assertEqual(out,
"error::Warning "
"ignore::BytesWarning "
"always::ResourceWarning "
"default::ResourceWarning "
"default::Warning")
try:
@ -573,19 +573,6 @@ class CmdLineTest(unittest.TestCase):
out = self.run_xdev("-c", code)
self.assertEqual(out, "True")
# Make sure that ResourceWarning emitted twice at the same line number
# is logged twice
filename = support.TESTFN
self.addCleanup(support.unlink, filename)
with open(filename, "w", encoding="utf8") as fp:
print("def func(): open(__file__)", file=fp)
print("func()", file=fp)
print("func()", file=fp)
fp.flush()
out = self.run_xdev(filename)
self.assertEqual(out.count(':1: ResourceWarning: '), 2, out)
class IgnoreEnvironmentTest(unittest.TestCase):