Force GC during weakref tests

Required to run the tests under PyPy with no refcount. See
https://github.com/mvantellingen/psycopg2-ctypes/pull/15#issuecomment-3274618
This commit is contained in:
Daniele Varrazzo 2011-12-26 22:35:33 +01:00
parent ede0e145dd
commit 702ae0a904
2 changed files with 4 additions and 0 deletions

View File

@ -435,9 +435,11 @@ class AsyncTests(unittest.TestCase):
self.assert_(self.conn.notices) self.assert_(self.conn.notices)
def test_async_cursor_gone(self): def test_async_cursor_gone(self):
import gc
cur = self.conn.cursor() cur = self.conn.cursor()
cur.execute("select 42;"); cur.execute("select 42;");
del cur del cur
gc.collect()
self.assertRaises(psycopg2.InterfaceError, self.wait, self.conn) self.assertRaises(psycopg2.InterfaceError, self.wait, self.conn)
# The connection is still usable # The connection is still usable

View File

@ -158,10 +158,12 @@ class ConnectionTests(unittest.TestCase):
def test_weakref(self): def test_weakref(self):
from weakref import ref from weakref import ref
import gc
conn = psycopg2.connect(dsn) conn = psycopg2.connect(dsn)
w = ref(conn) w = ref(conn)
conn.close() conn.close()
del conn del conn
gc.collect()
self.assert_(w() is None) self.assert_(w() is None)