<s> import os <EOL> from eventlet . support import six <EOL> from tests import patcher_test , skip_unless <EOL> from tests import get_database_auth <EOL> from tests . db_pool_test import postgres_requirement <EOL> psycopg_test_file = """<STR_LIT>""" <EOL> class PatchingPsycopg ( patcher_test . ProcessBase ) : <EOL> @ skip_unless ( postgres_requirement ) <EOL> def test_psycopg_patched ( self ) : <EOL> if '<STR_LIT>' not in os . environ : <EOL> psycopg_auth = get_database_auth ( ) [ '<STR_LIT>' ] <EOL> if isinstance ( psycopg_auth , str ) : <EOL> dsn = psycopg_auth <EOL> else : <EOL> dsn = "<STR_LIT:U+0020>" . join ( [ "<STR_LIT>" % ( k , v ) for k , v in six . iteritems ( psycopg_auth ) ] ) <EOL> os . environ [ '<STR_LIT>' ] = dsn <EOL> self . write_to_tempfile ( "<STR_LIT>" , psycopg_test_file ) <EOL> output , lines = self . launch_subprocess ( '<STR_LIT>' ) <EOL> if lines [ <NUM_LIT:0> ] . startswith ( '<STR_LIT>' ) : <EOL> print ( "<STR_LIT>" ) <EOL> return <EOL> assert lines [ <NUM_LIT:0> ] . startswith ( '<STR_LIT>' ) , output </s>
