mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 17:34:08 +03:00
Tests tweaked to run on all the supported versions
This commit is contained in:
parent
97311967e8
commit
294e7ae080
|
@ -22,7 +22,6 @@
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
# License for more details.
|
# License for more details.
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import string
|
import string
|
||||||
from testutils import unittest, decorate_all_tests, skip_if_no_iobase
|
from testutils import unittest, decorate_all_tests, skip_if_no_iobase
|
||||||
|
@ -31,17 +30,8 @@ from itertools import cycle, izip
|
||||||
|
|
||||||
import psycopg2
|
import psycopg2
|
||||||
import psycopg2.extensions
|
import psycopg2.extensions
|
||||||
from testconfig import dsn, green
|
from testconfig import dsn
|
||||||
|
from testutils import skip_copy_if_green
|
||||||
def skip_if_green(f):
|
|
||||||
def skip_if_green_(self):
|
|
||||||
if green:
|
|
||||||
return self.skipTest("copy in async mode currently not supported")
|
|
||||||
else:
|
|
||||||
return f(self)
|
|
||||||
|
|
||||||
return skip_if_green_
|
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info[0] < 3:
|
if sys.version_info[0] < 3:
|
||||||
_base = object
|
_base = object
|
||||||
|
@ -272,7 +262,7 @@ class CopyTests(unittest.TestCase):
|
||||||
self.assertEqual(curs.fetchone()[0], 2)
|
self.assertEqual(curs.fetchone()[0], 2)
|
||||||
|
|
||||||
|
|
||||||
decorate_all_tests(CopyTests, skip_if_green)
|
decorate_all_tests(CopyTests, skip_copy_if_green)
|
||||||
|
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
# License for more details.
|
# License for more details.
|
||||||
|
|
||||||
from testutils import unittest, skip_before_python, skip_before_postgres
|
from testutils import unittest, skip_before_python, skip_before_postgres
|
||||||
|
from testutils import skip_copy_if_green
|
||||||
|
|
||||||
from testconfig import dsn
|
from testconfig import dsn
|
||||||
|
|
||||||
|
@ -183,7 +184,6 @@ class ExceptionsTestCase(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(e.diag.sqlstate, '42P01')
|
self.assertEqual(e.diag.sqlstate, '42P01')
|
||||||
self.assertEqual(e.diag.severity, 'ERROR')
|
self.assertEqual(e.diag.severity, 'ERROR')
|
||||||
self.assertEqual(e.diag.statement_position, '15')
|
|
||||||
|
|
||||||
def test_diagnostics_life(self):
|
def test_diagnostics_life(self):
|
||||||
import gc
|
import gc
|
||||||
|
@ -210,6 +210,7 @@ class ExceptionsTestCase(unittest.TestCase):
|
||||||
gc.collect()
|
gc.collect()
|
||||||
assert(w() is None)
|
assert(w() is None)
|
||||||
|
|
||||||
|
@skip_copy_if_green
|
||||||
def test_diagnostics_copy(self):
|
def test_diagnostics_copy(self):
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
f = StringIO()
|
f = StringIO()
|
||||||
|
|
|
@ -222,6 +222,16 @@ def skip_if_no_superuser(f):
|
||||||
|
|
||||||
return skip_if_no_superuser_
|
return skip_if_no_superuser_
|
||||||
|
|
||||||
|
def skip_copy_if_green(f):
|
||||||
|
def skip_copy_if_green_(self):
|
||||||
|
from testconfig import green
|
||||||
|
if green:
|
||||||
|
return self.skipTest("copy in async mode currently not supported")
|
||||||
|
else:
|
||||||
|
return f(self)
|
||||||
|
|
||||||
|
return skip_copy_if_green_
|
||||||
|
|
||||||
|
|
||||||
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."""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user