summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/test_connection.py2
-rwxr-xr-xtests/test_module.py4
-rwxr-xr-xtests/test_quote.py10
-rw-r--r--tests/test_replication.py4
-rw-r--r--tests/testutils.py3
5 files changed, 12 insertions, 11 deletions
diff --git a/tests/test_connection.py b/tests/test_connection.py
index 8744488..833751b 100755
--- a/tests/test_connection.py
+++ b/tests/test_connection.py
@@ -465,7 +465,7 @@ class MakeDsnTestCase(ConnectingTestCase):
conn = self.connect()
d = conn.get_dsn_parameters()
self.assertEqual(d['dbname'], dbname) # the only param we can check reliably
- self.assertNotIn('password', d)
+ self.assert_('password' not in d, d)
class IsolationLevelsTestCase(ConnectingTestCase):
diff --git a/tests/test_module.py b/tests/test_module.py
index 1a9a19d..6a1606d 100755
--- a/tests/test_module.py
+++ b/tests/test_module.py
@@ -119,8 +119,8 @@ class ConnectTestCase(unittest.TestCase):
def test_int_port_param(self):
psycopg2.connect(database='sony', port=6543)
dsn = " %s " % self.args[0]
- self.assertIn(" dbname=sony ", dsn)
- self.assertIn(" port=6543 ", dsn)
+ self.assert_(" dbname=sony " in dsn, dsn)
+ self.assert_(" port=6543 " in dsn, dsn)
def test_empty_param(self):
psycopg2.connect(database='sony', password='')
diff --git a/tests/test_quote.py b/tests/test_quote.py
index f74fd85..72c9c1e 100755
--- a/tests/test_quote.py
+++ b/tests/test_quote.py
@@ -65,11 +65,13 @@ class QuotingTestCase(ConnectingTestCase):
curs = self.conn.cursor()
data = 'abcd\x01\x00cdefg'
- with self.assertRaises(ValueError) as e:
+ try:
curs.execute("SELECT %s", (data,))
-
- self.assertEquals(str(e.exception),
- 'A string literal cannot contain NUL (0x00) characters.')
+ except ValueError as e:
+ self.assertEquals(str(e),
+ 'A string literal cannot contain NUL (0x00) characters.')
+ else:
+ self.fail("ValueError not raised")
def test_binary(self):
data = b"""some data with \000\013 binary
diff --git a/tests/test_replication.py b/tests/test_replication.py
index ca99038..2ccd4c7 100644
--- a/tests/test_replication.py
+++ b/tests/test_replication.py
@@ -35,11 +35,7 @@ from testutils import ConnectingTestCase
class ReplicationTestCase(ConnectingTestCase):
def setUp(self):
- if not testconfig.repl_dsn:
- self.skipTest("replication tests disabled by default")
-
super(ReplicationTestCase, self).setUp()
-
self.slot = testconfig.repl_slot
self._slots = []
diff --git a/tests/testutils.py b/tests/testutils.py
index d0a34bc..1dd0c99 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -122,6 +122,9 @@ class ConnectingTestCase(unittest.TestCase):
Should raise a skip test if not available, but guard for None on
old Python versions.
"""
+ if repl_dsn is None:
+ return self.skipTest("replication tests disabled by default")
+
if 'dsn' not in kwargs:
kwargs['dsn'] = repl_dsn
import psycopg2