mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
use existing test object instead of defining a new class
This commit is contained in:
parent
ce3caf2e7a
commit
61dafcb6ca
1 changed files with 3 additions and 5 deletions
|
@ -602,22 +602,20 @@ class ReferencesTestCase(TestBase):
|
||||||
thresholds = gc.get_threshold()
|
thresholds = gc.get_threshold()
|
||||||
gc.set_threshold(1, 1, 1)
|
gc.set_threshold(1, 1, 1)
|
||||||
gc.collect()
|
gc.collect()
|
||||||
class A:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def callback(*args):
|
def callback(*args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
referenced = A()
|
referenced = C()
|
||||||
|
|
||||||
a = A()
|
a = C()
|
||||||
a.a = a
|
a.a = a
|
||||||
a.wr = makeref(referenced)
|
a.wr = makeref(referenced)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# now make sure the object and the ref get labeled as
|
# now make sure the object and the ref get labeled as
|
||||||
# cyclic trash:
|
# cyclic trash:
|
||||||
a = A()
|
a = C()
|
||||||
a.wrc = weakref.ref(referenced, callback)
|
a.wrc = weakref.ref(referenced, callback)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue