summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_xml_etree.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-02-11 11:11:44 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-02-11 11:11:44 (GMT)
commit94a619d48b90aba5b5b42004e84b290bb68f0664 (patch)
treefc77c9566191d8597af0be96f17a0b6d5bf82f45 /Lib/test/test_xml_etree.py
parente93b06a0a3255026802be19de249b3fdfe955b96 (diff)
downloadcpython-94a619d48b90aba5b5b42004e84b290bb68f0664.zip
cpython-94a619d48b90aba5b5b42004e84b290bb68f0664.tar.gz
cpython-94a619d48b90aba5b5b42004e84b290bb68f0664.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 358484d..44e3142 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -567,14 +567,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"
@@ -601,15 +598,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")