def postgres_requirement(_f): if psycopg2 is None: print("Skipping postgres tests, psycopg2 not importable") return False try: auth = tests.get_database_auth()['psycopg2'].copy() psycopg2.connect(**auth) return True except psycopg2.OperationalError: print("Skipping postgres tests, error when connecting") return False
def setUp(self): self._auth = get_database_auth()['MySQLdb'] self.create_db() self.connection = None self.connection = MySQLdb.connect(**self._auth) cursor = self.connection.cursor() cursor.execute("""CREATE TABLE gargleblatz ( a INTEGER );""") self.connection.commit() cursor.close()
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
def mysql_requirement(_f): verbose = os.environ.get('eventlet_test_mysql_verbose') if MySQLdb is None: if verbose: print(">> Skipping mysql tests, MySQLdb not importable", file=sys.stderr) return False try: auth = tests.get_database_auth()['MySQLdb'].copy() MySQLdb.connect(**auth) return True except MySQLdb.OperationalError: if verbose: print(">> Skipping mysql tests, error when connecting:", file=sys.stderr) traceback.print_exc() return False
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 psycopg_auth.iteritems()]) 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 self.assert_(lines[0].startswith('done'), output)
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 psycopg_auth.iteritems()]) 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 self.assert_(lines[0].startswith("done"), output)
def mysql_requirement(_f): """We want to skip tests if using pyevent, MySQLdb is not installed, or if there is no database running on the localhost that the auth file grants us access to. This errs on the side of skipping tests if everything is not right, but it's better than a million tests failing when you don't care about mysql support.""" if MySQLdb is False: print "Skipping mysql tests, MySQLdb not importable" return False try: auth = get_database_auth()['MySQLdb'].copy() MySQLdb.connect(**auth) return True except MySQLdb.OperationalError: print "Skipping mysql tests, error when connecting:" traceback.print_exc() return False
def mysql_requirement (_f): """We want to skip tests if using pyevent, MySQLdb is not installed, or if there is no database running on the localhost that the auth file grants us access to. This errs on the side of skipping tests if everything is not right, but it's better than a million tests failing when you don't care about mysql support.""" if MySQLdb is False: print "Skipping mysql tests, MySQLdb not importable" return False try: auth = get_database_auth()['MySQLdb'].copy() MySQLdb.connect(**auth) return True except MySQLdb.OperationalError: print "Skipping mysql tests, error when connecting:" traceback.print_exc() return False
def setUp(self): self._dbmodule = psycopg2 self._auth = tests.get_database_auth()['psycopg2'] super(Psycopg2ConnectionPool, self).setUp()
def setUp(self): self._dbmodule = MySQLdb self._auth = tests.get_database_auth()['MySQLdb'] super(MysqlConnectionPool, self).setUp()