This commit is contained in:
@@ -107,34 +107,4 @@ def test_signature_preservation():
|
||||
pass
|
||||
|
||||
assert "x: int" in str(TestClass.__signature__)
|
||||
assert "y: str = 'hello'" in str(TestClass.__signature__)
|
||||
|
||||
def test_weakset_vs_set_behavior(clean_registry):
|
||||
# Test WeakSet vs set reference behavior
|
||||
class Item(Registry):
|
||||
pass
|
||||
|
||||
# Create item and get references
|
||||
item = Item()
|
||||
item_id = id(item)
|
||||
reg_set = instances(Item, weak=False)
|
||||
reg_weak = instances(Item, weak=True)
|
||||
|
||||
# Verify initial state
|
||||
assert len(reg_set) == 1
|
||||
assert len(reg_weak) == 1
|
||||
|
||||
# Delete the only reference
|
||||
del item
|
||||
|
||||
# Force garbage collection
|
||||
import gc
|
||||
gc.collect()
|
||||
|
||||
# Verify WeakSet cleared but regular set maintains reference
|
||||
assert len(reg_weak) == 0 # WeakSet should be empty
|
||||
assert len(reg_set) == 1 # Regular set keeps reference
|
||||
|
||||
# Extra verification that the object was really collected
|
||||
for ref in reg_weak:
|
||||
assert id(ref) != item_id # Shouldn't find our item
|
||||
assert "y: str = 'hello'" in str(TestClass.__signature__)
|
||||
Reference in New Issue
Block a user