예제 #1
0
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
예제 #2
0
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
예제 #3
0
 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
예제 #5
0
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
예제 #6
0
 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)
예제 #8
0
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
예제 #9
0
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
예제 #10
0
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
예제 #11
0
 def setUp(self):
     self._dbmodule = psycopg2
     self._auth = tests.get_database_auth()['psycopg2']
     super(Psycopg2ConnectionPool, self).setUp()
예제 #12
0
 def setUp(self):
     self._dbmodule = MySQLdb
     self._auth = tests.get_database_auth()['MySQLdb']
     super(MysqlConnectionPool, self).setUp()
예제 #13
0
 def setUp(self):
     self._dbmodule = psycopg2
     self._auth = tests.get_database_auth()['psycopg2']
     super(Psycopg2ConnectionPool, self).setUp()
예제 #14
0
 def setUp(self):
     self._dbmodule = MySQLdb
     self._auth = tests.get_database_auth()['MySQLdb']
     super(MysqlConnectionPool, self).setUp()