X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=eventlet%2Ftests%2Fpatcher_psycopg_test.py;fp=eventlet%2Ftests%2Fpatcher_psycopg_test.py;h=0000000000000000000000000000000000000000;hb=358bd9258c2b6d2ee74de4dfd07a5123107abad4;hp=83ffdfae85e29d4051817575922637885fb5b6c3;hpb=376ff3bfe7071cc0793184a378c4e74508fb0d97;p=packages%2Ftrusty%2Fpython-eventlet.git diff --git a/eventlet/tests/patcher_psycopg_test.py b/eventlet/tests/patcher_psycopg_test.py deleted file mode 100644 index 83ffdfa..0000000 --- a/eventlet/tests/patcher_psycopg_test.py +++ /dev/null @@ -1,58 +0,0 @@ -import os - -from eventlet.support import six - -from tests import patcher_test, skip_unless -from tests import get_database_auth -from tests.db_pool_test import postgres_requirement - -psycopg_test_file = """ -import os -import sys -import eventlet -eventlet.monkey_patch() -from eventlet import patcher -if not patcher.is_monkey_patched('psycopg'): - print("Psycopg not monkeypatched") - sys.exit(0) - -count = [0] -def tick(totalseconds, persecond): - for i in range(totalseconds*persecond): - count[0] += 1 - eventlet.sleep(1.0/persecond) - -dsn = os.environ['PSYCOPG_TEST_DSN'] -import psycopg2 -def fetch(num, secs): - conn = psycopg2.connect(dsn) - cur = conn.cursor() - for i in range(num): - cur.execute("select pg_sleep(%s)", (secs,)) - -f = eventlet.spawn(fetch, 2, 1) -t = eventlet.spawn(tick, 2, 100) -f.wait() -assert count[0] > 100, count[0] -print("done") -""" - - -class PatchingPsycopg(patcher_test.ProcessBase): - @skip_unless(postgres_requirement) - def test_psycopg_patched(self): - if 'PSYCOPG_TEST_DSN' not in os.environ: - # construct a non-json dsn for the subprocess - psycopg_auth = get_database_auth()['psycopg2'] - if isinstance(psycopg_auth, str): - dsn = psycopg_auth - else: - dsn = " ".join(["%s=%s" % (k, v) for k, v in six.iteritems(psycopg_auth)]) - os.environ['PSYCOPG_TEST_DSN'] = dsn - self.write_to_tempfile("psycopg_patcher", psycopg_test_file) - output, lines = self.launch_subprocess('psycopg_patcher.py') - if lines[0].startswith('Psycopg not monkeypatched'): - print("Can't test psycopg2 patching; it's not installed.") - return - # if there's anything wrong with the test program it'll have a stack trace - assert lines[0].startswith('done'), output