mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 01:14:09 +03:00
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:
parent
ede0e145dd
commit
702ae0a904
|
@ -435,9 +435,11 @@ class AsyncTests(unittest.TestCase):
|
|||
self.assert_(self.conn.notices)
|
||||
|
||||
def test_async_cursor_gone(self):
|
||||
import gc
|
||||
cur = self.conn.cursor()
|
||||
cur.execute("select 42;");
|
||||
del cur
|
||||
gc.collect()
|
||||
self.assertRaises(psycopg2.InterfaceError, self.wait, self.conn)
|
||||
|
||||
# The connection is still usable
|
||||
|
|
|
@ -158,10 +158,12 @@ class ConnectionTests(unittest.TestCase):
|
|||
|
||||
def test_weakref(self):
|
||||
from weakref import ref
|
||||
import gc
|
||||
conn = psycopg2.connect(dsn)
|
||||
w = ref(conn)
|
||||
conn.close()
|
||||
del conn
|
||||
gc.collect()
|
||||
self.assert_(w() is None)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user