MCPcopy Index your code
hub / github.com/python/cpython / test_bpo_31728

Method test_bpo_31728

Lib/test/test_xml_etree_c.py:91–121  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

89 support.gc_collect()
90
91 def test_bpo_31728(self):
92 # A crash or an assertion failure shouldn't happen, in case garbage
93 # collection triggers a call to clear() or a reading of text or tail,
94 # while a setter or clear() or __setstate__() is already running.
95 elem = cET.Element('elem')
96 class X:
97 def __del__(self):
98 elem.text
99 elem.tail
100 elem.clear()
101
102 elem.text = X()
103 elem.clear() # shouldn't crash
104
105 elem.tail = X()
106 elem.clear() # shouldn't crash
107
108 elem.text = X()
109 elem.text = X() # shouldn't crash
110 elem.clear()
111
112 elem.tail = X()
113 elem.tail = X() # shouldn't crash
114 elem.clear()
115
116 elem.text = X()
117 elem.__setstate__({'tag': 42}) # shouldn't cause an assertion failure
118 elem.clear()
119
120 elem.tail = X()
121 elem.__setstate__({'tag': 42}) # shouldn't cause an assertion failure
122
123 @support.cpython_only
124 def test_uninitialized_parser(self):

Callers

nothing calls this directly

Calls 3

clearMethod · 0.95
XClass · 0.70
__setstate__Method · 0.45

Tested by

no test coverage detected