Tests can be run again different coroutine libraries.

Use PSYCOPG2_TEST_GREEN=<something>, where <something> is 1 or a library
name. Currently eventlet is supported.
This commit is contained in:
Daniele Varrazzo 2010-05-19 11:10:39 +01:00
parent 23391a3c55
commit b597ccf917

View File

@ -11,9 +11,16 @@ dbuser = os.environ.get('PSYCOPG2_TESTDB_USER', None)
# Check if we want to test psycopg's green path.
green = os.environ.get('PSYCOPG2_TEST_GREEN', None)
if green:
if green == '1':
from psycopg2.extras import wait_select as wait_callback
elif green == 'eventlet':
from eventlet.support.psycopg2_patcher import eventlet_wait_callback \
as wait_callback
else:
raise ValueError("please set 'PSYCOPG2_TEST_GREEN' to a valid value")
import psycopg2.extensions
import psycopg2.extras
psycopg2.extensions.set_wait_callback(psycopg2.extras.wait_select)
psycopg2.extensions.set_wait_callback(wait_callback)
# Construct a DSN to connect to the test database:
dsn = 'dbname=%s' % dbname