Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
a5e82204
Kaydet (Commit)
a5e82204
authored
Mar 31, 2012
tarafından
Eli Bendersky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix the tests of GC collection in ET.Element according to Benjamin's recommendations
üst
c6897854
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
23 deletions
+21
-23
test_xml_etree.py
Lib/test/test_xml_etree.py
+21
-23
No files found.
Lib/test/test_xml_etree.py
Dosyayı görüntüle @
a5e82204
...
...
@@ -14,14 +14,14 @@
# Don't re-import "xml.etree.ElementTree" module in the docstring,
# except if the test is specific to the Python implementation.
import
gc
import
html
import
io
import
sys
import
unittest
import
weakref
from
test
import
support
from
test.support
import
findfile
,
import_fresh_module
from
test.support
import
findfile
,
import_fresh_module
,
gc_collect
pyET
=
import_fresh_module
(
'xml.etree.ElementTree'
,
blocked
=
[
'_elementtree'
])
...
...
@@ -1848,28 +1848,26 @@ class BasicElementTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
e
.
insert
,
0
,
'foo'
)
def
test_cyclic_gc
(
self
):
class
ShowGC
:
def
__init__
(
self
,
flaglist
):
self
.
flaglist
=
flaglist
def
__del__
(
self
):
self
.
flaglist
.
append
(
1
)
# Test the shortest cycle: lst->element->lst
fl
=
[]
lst
=
[
ShowGC
(
fl
)]
lst
.
append
(
ET
.
Element
(
'joe'
,
attr
=
lst
))
del
lst
gc
.
collect
()
self
.
assertEqual
(
fl
,
[
1
])
# A longer cycle: lst->e->e2->lst
fl
=
[]
class
Dummy
:
pass
# Test the shortest cycle: d->element->d
d
=
Dummy
()
d
.
dummyref
=
ET
.
Element
(
'joe'
,
attr
=
d
)
wref
=
weakref
.
ref
(
d
)
del
d
gc_collect
()
self
.
assertIsNone
(
wref
())
# A longer cycle: d->e->e2->d
e
=
ET
.
Element
(
'joe'
)
lst
=
[
ShowGC
(
fl
),
e
]
e2
=
ET
.
SubElement
(
e
,
'foo'
,
attr
=
lst
)
del
lst
,
e
,
e2
gc
.
collect
()
self
.
assertEqual
(
fl
,
[
1
])
d
=
Dummy
()
d
.
dummyref
=
e
wref
=
weakref
.
ref
(
d
)
e2
=
ET
.
SubElement
(
e
,
'foo'
,
attr
=
d
)
del
d
,
e
,
e2
gc_collect
()
self
.
assertIsNone
(
wref
())
class
ElementTreeTest
(
unittest
.
TestCase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment