Update tests/test_utils_registry.py
Run CI Tests / test (push) Successful in 1m0s

This commit is contained in:
2025-08-05 21:51:32 +02:00
parent 6050f6b4b0
commit 4bdfe9c551
+1 -31
View File
@@ -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__)