summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_xml_etree.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-02-11 11:12:19 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-02-11 11:12:19 (GMT)
commit2feb64258558fc280f1d87bec211d83def48a9f0 (patch)
treed370a07dff4adfca5ba740cbdf603d7b6b31c9c1 /Lib/test/test_xml_etree.py
parent885bdc4946890f4bb80557fab80c3874b2cc4d39 (diff)
parent94a619d48b90aba5b5b42004e84b290bb68f0664 (diff)
downloadcpython-2feb64258558fc280f1d87bec211d83def48a9f0.zip
cpython-2feb64258558fc280f1d87bec211d83def48a9f0.tar.gz
cpython-2feb64258558fc280f1d87bec211d83def48a9f0.tar.bz2
Issue #26325: Added test.support.check_no_resource_warning() to check that
no ResourceWarning is emitted.
Diffstat (limited to 'Lib/test/test_xml_etree.py')
-rw-r--r--Lib/test/test_xml_etree.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 39e608b..bfd7215 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -569,14 +569,11 @@ class ElementTreeTest(unittest.TestCase):
self.assertFalse(f.closed)
self.assertEqual(str(cm.exception), "unknown event 'bogus'")
- with warnings.catch_warnings(record=True) as w:
- warnings.filterwarnings("always", category=ResourceWarning)
+ with support.check_no_resource_warning(self):
with self.assertRaises(ValueError) as cm:
iterparse(SIMPLE_XMLFILE, events)
self.assertEqual(str(cm.exception), "unknown event 'bogus'")
del cm
- support.gc_collect()
- self.assertEqual(w, [])
source = io.BytesIO(
b"<?xml version='1.0' encoding='iso-8859-1'?>\n"
@@ -603,15 +600,12 @@ class ElementTreeTest(unittest.TestCase):
it = iterparse(TESTFN)
action, elem = next(it)
self.assertEqual((action, elem.tag), ('end', 'document'))
- with warnings.catch_warnings(record=True) as w:
- warnings.filterwarnings("always", category=ResourceWarning)
+ with support.check_no_resource_warning(self):
with self.assertRaises(ET.ParseError) as cm:
next(it)
self.assertEqual(str(cm.exception),
'junk after document element: line 1, column 12')
del cm, it
- support.gc_collect()
- self.assertEqual(w, [])
def test_writefile(self):
elem = ET.Element("tag")