From b597ccf91718665e01efc5fe95e6b97c66f5d056 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 19 May 2010 11:10:39 +0100 Subject: [PATCH] Tests can be run again different coroutine libraries. Use PSYCOPG2_TEST_GREEN=, where is 1 or a library name. Currently eventlet is supported. --- tests/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 2b1ab226..2a799481 100755 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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