mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-07-03 11:13:04 +03:00
Bail out early from tests if connection to the test db fails.
This commit is contained in:
parent
5f80dd38c4
commit
46a5f140c7
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from testutils import unittest
|
from testutils import unittest
|
||||||
|
|
||||||
dbname = os.environ.get('PSYCOPG2_TESTDB', 'psycopg2_test')
|
dbname = os.environ.get('PSYCOPG2_TESTDB', 'psycopg2_test')
|
||||||
|
@ -31,6 +32,17 @@ if dbport is not None:
|
||||||
if dbuser is not None:
|
if dbuser is not None:
|
||||||
dsn += ' user=%s' % dbuser
|
dsn += ' user=%s' % dbuser
|
||||||
|
|
||||||
|
# If connection to test db fails, bail out early.
|
||||||
|
import psycopg2
|
||||||
|
try:
|
||||||
|
cnn = psycopg2.connect(dsn)
|
||||||
|
except Exception, e:
|
||||||
|
print "Failed connection to test db:", e.__class__.__name__, e
|
||||||
|
print "Please set env vars 'PSYCOPG2_TESTDB*' to valid values."
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
cnn.close()
|
||||||
|
|
||||||
import bugX000
|
import bugX000
|
||||||
import extras_dictcursor
|
import extras_dictcursor
|
||||||
import test_dates
|
import test_dates
|
||||||
|
|
Loading…
Reference in New Issue
Block a user