mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +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)
|
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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user