mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
Skip tests on python implementations without getrefcount()
PyPy is one of these. Conflicts: tests/test_cursor.py tests/test_module.py
This commit is contained in:
parent
50b68aa987
commit
d0f49f9887
|
@ -26,8 +26,8 @@ import time
|
||||||
import psycopg2
|
import psycopg2
|
||||||
import psycopg2.extensions
|
import psycopg2.extensions
|
||||||
from psycopg2.extensions import b
|
from psycopg2.extensions import b
|
||||||
from testconfig import dsn
|
from testconfig import dsn, unittest, skip_before_postgres
|
||||||
from testutils import unittest, skip_before_postgres, skip_if_no_namedtuple
|
from testutils import skip_if_no_namedtuple, skip_if_no_getrefcount
|
||||||
|
|
||||||
class CursorTests(unittest.TestCase):
|
class CursorTests(unittest.TestCase):
|
||||||
|
|
||||||
|
@ -103,6 +103,7 @@ class CursorTests(unittest.TestCase):
|
||||||
self.assertEqual(b('SELECT 10.3;'),
|
self.assertEqual(b('SELECT 10.3;'),
|
||||||
cur.mogrify("SELECT %s;", (Decimal("10.3"),)))
|
cur.mogrify("SELECT %s;", (Decimal("10.3"),)))
|
||||||
|
|
||||||
|
@skip_if_no_getrefcount
|
||||||
def test_mogrify_leak_on_multiple_reference(self):
|
def test_mogrify_leak_on_multiple_reference(self):
|
||||||
# issue #81: reference leak when a parameter value is referenced
|
# issue #81: reference leak when a parameter value is referenced
|
||||||
# more than once from a dict.
|
# more than once from a dict.
|
||||||
|
@ -163,6 +164,7 @@ class CursorTests(unittest.TestCase):
|
||||||
curs = self.conn.cursor()
|
curs = self.conn.cursor()
|
||||||
w = ref(curs)
|
w = ref(curs)
|
||||||
del curs
|
del curs
|
||||||
|
import gc; gc.collect()
|
||||||
self.assert_(w() is None)
|
self.assert_(w() is None)
|
||||||
|
|
||||||
def test_null_name(self):
|
def test_null_name(self):
|
||||||
|
|
|
@ -223,6 +223,15 @@ def skip_if_no_superuser(f):
|
||||||
return skip_if_no_superuser_
|
return skip_if_no_superuser_
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
def script_to_py3(script):
|
||||||
"""Convert a script to Python3 syntax if required."""
|
"""Convert a script to Python3 syntax if required."""
|
||||||
if sys.version_info[0] < 3:
|
if sys.version_info[0] < 3:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user