mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
2008-04-21 Jorgen Austvik <Jorgen.Austvik@sun.com>
* tests/*.py: use the DSN constructed in tests/__init__.py. * tests/__init__.py: allow setting the host, port and user for the DSN used by the tests through the environment.
This commit is contained in:
parent
962c5a9a5f
commit
2f3f4c1258
|
@ -1,3 +1,10 @@
|
||||||
|
2008-04-21 James Henstridge <james@jamesh.id.au>
|
||||||
|
|
||||||
|
* tests/*.py: use the DSN constructed in tests/__init__.py.
|
||||||
|
|
||||||
|
* tests/__init__.py: allow setting the host, port and user for the
|
||||||
|
DSN used by the tests through the environment.
|
||||||
|
|
||||||
2008-03-17 Federico Di Gregorio <fog@initd.org>
|
2008-03-17 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
* Release 2.0.7.
|
* Release 2.0.7.
|
||||||
|
|
|
@ -3,6 +3,18 @@ import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
dbname = os.environ.get('PSYCOPG2_TESTDB', 'psycopg2_test')
|
dbname = os.environ.get('PSYCOPG2_TESTDB', 'psycopg2_test')
|
||||||
|
dbhost = os.environ.get('PSYCOPG2_TESTDB_HOST', None)
|
||||||
|
dbport = os.environ.get('PSYCOPG2_TESTDB_PORT', None)
|
||||||
|
dbuser = os.environ.get('PSYCOPG2_TESTDB_USER', None)
|
||||||
|
|
||||||
|
# Construct a DSN to connect to the test database:
|
||||||
|
dsn = 'dbname=%s' % dbname
|
||||||
|
if dbhost is not None:
|
||||||
|
dsn += ' host=%s' % dbhost
|
||||||
|
if dbport is not None:
|
||||||
|
dsn += ' port=%s' % dbport
|
||||||
|
if dbuser is not None:
|
||||||
|
dsn += ' user=%s' % dbuser
|
||||||
|
|
||||||
import bugX000
|
import bugX000
|
||||||
import extras_dictcursor
|
import extras_dictcursor
|
||||||
|
|
|
@ -24,7 +24,7 @@ class ExtrasDictCursorTests(unittest.TestCase):
|
||||||
"""Test if DictCursor extension class works."""
|
"""Test if DictCursor extension class works."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.conn = psycopg2.connect("dbname=%s" % tests.dbname)
|
self.conn = psycopg2.connect(tests.dsn)
|
||||||
curs = self.conn.cursor()
|
curs = self.conn.cursor()
|
||||||
curs.execute("CREATE TEMPORARY TABLE ExtrasDictCursorTests (foo text)")
|
curs.execute("CREATE TEMPORARY TABLE ExtrasDictCursorTests (foo text)")
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import tests
|
||||||
class ConnectionTests(unittest.TestCase):
|
class ConnectionTests(unittest.TestCase):
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
return psycopg2.connect("dbname=%s" % tests.dbname)
|
return psycopg2.connect(tests.dsn)
|
||||||
|
|
||||||
def test_closed_attribute(self):
|
def test_closed_attribute(self):
|
||||||
conn = self.connect()
|
conn = self.connect()
|
||||||
|
|
|
@ -9,7 +9,7 @@ import tests
|
||||||
class CommonDatetimeTestsMixin:
|
class CommonDatetimeTestsMixin:
|
||||||
|
|
||||||
def execute(self, *args):
|
def execute(self, *args):
|
||||||
conn = psycopg2.connect("dbname=%s" % tests.dbname)
|
conn = psycopg2.connect(tests.dsn)
|
||||||
curs = conn.cursor()
|
curs = conn.cursor()
|
||||||
curs.execute(*args)
|
curs.execute(*args)
|
||||||
return curs.fetchone()[0]
|
return curs.fetchone()[0]
|
||||||
|
|
|
@ -9,7 +9,7 @@ import tests
|
||||||
class Psycopg2TestCase(dbapi20.DatabaseAPI20Test):
|
class Psycopg2TestCase(dbapi20.DatabaseAPI20Test):
|
||||||
driver = psycopg2
|
driver = psycopg2
|
||||||
connect_args = ()
|
connect_args = ()
|
||||||
connect_kw_args = {'dsn': 'dbname=%s' % tests.dbname}
|
connect_kw_args = {'dsn': tests.dsn}
|
||||||
|
|
||||||
lower_func = 'lower' # For stored procedure test
|
lower_func = 'lower' # For stored procedure test
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class QuotingTestCase(unittest.TestCase):
|
||||||
http://www.postgresql.org/docs/8.1/static/runtime-config-compatible.html
|
http://www.postgresql.org/docs/8.1/static/runtime-config-compatible.html
|
||||||
"""
|
"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.conn = psycopg2.connect("dbname=%s" % tests.dbname)
|
self.conn = psycopg2.connect(tests.dsn)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
|
|
|
@ -11,7 +11,7 @@ import tests
|
||||||
class TransactionTests(unittest.TestCase):
|
class TransactionTests(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.conn = psycopg2.connect("dbname=%s" % tests.dbname)
|
self.conn = psycopg2.connect(tests.dsn)
|
||||||
self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
|
self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
|
||||||
curs = self.conn.cursor()
|
curs = self.conn.cursor()
|
||||||
curs.execute('''
|
curs.execute('''
|
||||||
|
@ -75,7 +75,7 @@ class DeadlockSerializationTests(unittest.TestCase):
|
||||||
"""Test deadlock and serialization failure errors."""
|
"""Test deadlock and serialization failure errors."""
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
conn = psycopg2.connect("dbname=%s" % tests.dbname)
|
conn = psycopg2.connect(tests.dsn)
|
||||||
conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
|
conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ class QueryCancelationTests(unittest.TestCase):
|
||||||
"""Tests for query cancelation."""
|
"""Tests for query cancelation."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.conn = psycopg2.connect("dbname=%s" % tests.dbname)
|
self.conn = psycopg2.connect(tests.dsn)
|
||||||
self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
|
self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
|
||||||
|
|
||||||
def test_statement_timeout(self):
|
def test_statement_timeout(self):
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TypesBasicTests(unittest.TestCase):
|
||||||
"""Test presence of mandatory attributes and methods."""
|
"""Test presence of mandatory attributes and methods."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.conn = psycopg2.connect("dbname=%s" % tests.dbname)
|
self.conn = psycopg2.connect(tests.dsn)
|
||||||
|
|
||||||
def execute(self, *args):
|
def execute(self, *args):
|
||||||
curs = self.conn.cursor()
|
curs = self.conn.cursor()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user