summaryrefslogtreecommitdiff
path: root/tests/test_cursor.py
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2010-11-28 16:00:32 +0000
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2010-11-28 17:29:37 +0000
commit361786f4a83bc79e65fbc53095ebcc37d62fdc99 (patch)
tree0c4e60d800c06a89a9c41ba03e09a2a9c61d97bb /tests/test_cursor.py
parent598b9424d27155b49d8ad1ca17dfa0c27b5ad974 (diff)
downloadpsycopg2-361786f4a83bc79e65fbc53095ebcc37d62fdc99.tar.gz
More careful connections handling during tests.
Diffstat (limited to 'tests/test_cursor.py')
-rw-r--r--tests/test_cursor.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/test_cursor.py b/tests/test_cursor.py
index ada2d60..90b7cf2 100644
--- a/tests/test_cursor.py
+++ b/tests/test_cursor.py
@@ -7,11 +7,14 @@ import tests
class CursorTests(unittest.TestCase):
- def connect(self):
- return psycopg2.connect(tests.dsn)
+ def setUp(self):
+ self.conn = psycopg2.connect(tests.dsn)
+
+ def tearDown(self):
+ self.conn.close()
def test_executemany_propagate_exceptions(self):
- conn = self.connect()
+ conn = self.conn
cur = conn.cursor()
cur.execute("create temp table test_exc (data int);")
def buggygen():
@@ -19,10 +22,9 @@ class CursorTests(unittest.TestCase):
self.assertRaises(ZeroDivisionError,
cur.executemany, "insert into test_exc values (%s)", buggygen())
cur.close()
- conn.close()
def test_mogrify_unicode(self):
- conn = self.connect()
+ conn = self.conn
cur = conn.cursor()
# test consistency between execute and mogrify.
@@ -60,7 +62,7 @@ class CursorTests(unittest.TestCase):
except:
return
- conn = self.connect()
+ conn = self.conn
cur = conn.cursor()
self.assertEqual('SELECT 10.3;',
cur.mogrify("SELECT %s;", (Decimal("10.3"),)))