mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-26 02:43:43 +03:00
Skip tests on python implementations without getrefcount()
PyPy is one of these.
This commit is contained in:
parent
bbe0bf955c
commit
a44db81d9b
|
@ -27,7 +27,7 @@ import psycopg2
|
|||
import psycopg2.extensions
|
||||
from psycopg2.extensions import b
|
||||
from testutils import unittest, ConnectingTestCase, skip_before_postgres
|
||||
from testutils import skip_if_no_namedtuple
|
||||
from testutils import skip_if_no_namedtuple, skip_if_no_getrefcount
|
||||
|
||||
class CursorTests(ConnectingTestCase):
|
||||
|
||||
|
@ -97,6 +97,7 @@ class CursorTests(ConnectingTestCase):
|
|||
self.assertEqual(b('SELECT 10.3;'),
|
||||
cur.mogrify("SELECT %s;", (Decimal("10.3"),)))
|
||||
|
||||
@skip_if_no_getrefcount
|
||||
def test_mogrify_leak_on_multiple_reference(self):
|
||||
# issue #81: reference leak when a parameter value is referenced
|
||||
# more than once from a dict.
|
||||
|
@ -157,6 +158,7 @@ class CursorTests(ConnectingTestCase):
|
|||
curs = self.conn.cursor()
|
||||
w = ref(curs)
|
||||
del curs
|
||||
import gc; gc.collect()
|
||||
self.assert_(w() is None)
|
||||
|
||||
def test_null_name(self):
|
||||
|
|
|
@ -199,7 +199,7 @@ class ExceptionsTestCase(ConnectingTestCase):
|
|||
self.assertEqual(diag.sqlstate, '42P01')
|
||||
|
||||
del diag
|
||||
gc.collect()
|
||||
gc.collect(); gc.collect()
|
||||
assert(w() is None)
|
||||
|
||||
@skip_copy_if_green
|
||||
|
|
|
@ -293,6 +293,15 @@ def skip_if_green(reason):
|
|||
|
||||
skip_copy_if_green = skip_if_green("copy in async mode currently not supported")
|
||||
|
||||
def skip_if_no_getrefcount(f):
|
||||
@wraps(f)
|
||||
def skip_if_no_getrefcount_(self):
|
||||
if not hasattr(sys, 'getrefcount'):
|
||||
return self.skipTest('skipped, no sys.getrefcount()')
|
||||
else:
|
||||
return f(self)
|
||||
return skip_if_no_getrefcount_
|
||||
|
||||
def script_to_py3(script):
|
||||
"""Convert a script to Python3 syntax if required."""
|
||||
if sys.version_info[0] < 3:
|
||||
|
|
Loading…
Reference in New Issue
Block a user