@@ -1168,14 +1168,15 @@ def __init__(self):
11681168 self._z = weakref.ref(Class, lambda x: None)
11691169
11701170 def __del__(self):
1171- assert self._z() is None, "Type weakref is not None"
1171+ if self._z() is None:
1172+ print("Type weakref is None as expected")
11721173
11731174 Class()
11741175
11751176 test()
11761177 """
1177- _ , _ , stderr = assert_python_ok ("-c" , code )
1178- assert b"Type weakref is not None" not in stderr
1178+ _ , stdout , _ = assert_python_ok ("-c" , code )
1179+ assert b"Type weakref is None as expected" in stdout
11791180
11801181 def test_type_weakref_without_callback_should_be_not_none (self ):
11811182 # This test checks that weakrefs for types without callbacks
@@ -1190,16 +1191,18 @@ def __init__(self):
11901191 self._z = weakref.ref(Class)
11911192
11921193 def __del__(self):
1193- assert self._x() is None, "Instance weakref is not None"
1194- assert self._z() is Class, "Type weakref is not Class"
1194+ if self._x() is None:
1195+ print("Instance weakref is None as expected")
1196+ if self._z() is Class:
1197+ print("Type weakref is Class as expected")
11951198
11961199 Class()
11971200
11981201 test()
11991202 """
1200- _ , _ , stderr = assert_python_ok ("-c" , code )
1201- assert b"Instance weakref is not None" not in stderr
1202- assert b"Type weakref is not Class" not in stderr
1203+ _ , stdout , _ = assert_python_ok ("-c" , code )
1204+ assert b"Instance weakref is None as expected" in stdout
1205+ assert b"Type weakref is Class as expected" in stdout
12031206
12041207
12051208class IncrementalGCTests (unittest .TestCase ):
0 commit comments