Commits

jason kirtland  committed f2acc0a

Update test suite to pass under pypy1.5 (gc collection for refs)

  • Participants
  • Parent commits efda410

Comments (0)

Files changed (1)

File tests/test_signals.py

 
 
 jython = sys.platform.startswith('java')
+pypy = hasattr(sys, 'pypy_version_info')
 
 
-def collect():
+def collect_acyclic_refs():
+    # cpython releases these immediately without a collection
+    if jython or pypy:
+        gc.collect()
     if jython:
-        gc.collect()
         time.sleep(0.1)
 
 
 
     del sentinel[:]  # holds a ref to receiver2
     del receiver2
-    collect()
+    collect_acyclic_refs()
 
     # no disconnect signal is fired
     assert len(sentinel) == 0
 
     # force sender2 to go out of scope
     del sender2
-    collect()
+    collect_acyclic_refs()
 
     # no disconnect signal is fired
     assert len(sentinel) == 1
     assert s1 is ns.signal('abc')
     assert s1 is not ns.signal('def')
     assert 'abc' in ns
-    collect()
+    collect_acyclic_refs()
 
     # weak by default, already out of scope
     assert 'def' not in ns
     del s1
-    collect()
+    collect_acyclic_refs()
 
     assert 'abc' not in ns
 
         sig.connect(received, weak=True)
 
     del received
-    collect()
+    collect_acyclic_refs()
 
     assert not sentinel
     sig.send()
     sig.connect(received, weak=False)
 
     del received
-    collect()
+    collect_acyclic_refs()
 
     assert not sentinel
     sig.send()
     sig.send()
     assert sentinel
     del receiver
-    collect()
+    collect_acyclic_refs()
 
     sig.send()
     assert len(sentinel) == 1
     assert sentinel == [obj]
     del sentinel[:]
     del obj
-    collect()
+    collect_acyclic_refs()
 
     # general index isn't cleaned up
     assert sig.receivers
     assert sig.receivers
 
     del receiver
-    collect()
+    collect_acyclic_refs()
     assert sig.receivers
 
 
     assert sig.has_receivers_for(o)
 
     del received
-    collect()
+    collect_acyclic_refs()
 
     assert not sig.has_receivers_for('xyz')
     assert list(sig.receivers_for('xyz')) == []