From 702ae0a904a4a0974ce48dc575aff38ef568f070 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Mon, 26 Dec 2011 22:35:33 +0100 Subject: [PATCH] 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 --- tests/test_async.py | 2 ++ tests/test_connection.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/test_async.py b/tests/test_async.py index 07a3c42d..08113c4f 100755 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -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 diff --git a/tests/test_connection.py b/tests/test_connection.py index a887313a..f6e8cc8d 100755 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -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)