Tests tweaked to run on all the supported versions

This commit is contained in:
Daniele Varrazzo 2013-03-18 10:06:07 +00:00
parent 97311967e8
commit 294e7ae080
3 changed files with 15 additions and 14 deletions

View File

@ -22,7 +22,6 @@
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.
import os
import sys
import string
from testutils import unittest, decorate_all_tests, skip_if_no_iobase
@ -31,17 +30,8 @@ from itertools import cycle, izip
import psycopg2
import psycopg2.extensions
from testconfig import dsn, 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_
from testconfig import dsn
from testutils import skip_copy_if_green
if sys.version_info[0] < 3:
_base = object
@ -272,7 +262,7 @@ class CopyTests(unittest.TestCase):
self.assertEqual(curs.fetchone()[0], 2)
decorate_all_tests(CopyTests, skip_if_green)
decorate_all_tests(CopyTests, skip_copy_if_green)
def test_suite():

View File

@ -23,6 +23,7 @@
# License for more details.
from testutils import unittest, skip_before_python, skip_before_postgres
from testutils import skip_copy_if_green
from testconfig import dsn
@ -183,7 +184,6 @@ class ExceptionsTestCase(unittest.TestCase):
self.assertEqual(e.diag.sqlstate, '42P01')
self.assertEqual(e.diag.severity, 'ERROR')
self.assertEqual(e.diag.statement_position, '15')
def test_diagnostics_life(self):
import gc
@ -210,6 +210,7 @@ class ExceptionsTestCase(unittest.TestCase):
gc.collect()
assert(w() is None)
@skip_copy_if_green
def test_diagnostics_copy(self):
from StringIO import StringIO
f = StringIO()

View File

@ -222,6 +222,16 @@ def skip_if_no_superuser(f):
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):
"""Convert a script to Python3 syntax if required."""