[test] skip if we can't connect to a local mysql

http://dev.mysql.com/doc/refman/5.6/en/error-messages-client.html says error code 2002 is the equivalent of 2003 for non-local instances.

authorJulien Cristau <julien.cristau@logilab.fr>
changesetfa3cb6e47777
branchdefault
phasepublic
hiddenno
parent revision#d9a772cdbb19 [postgres] Take schema into account in pg_table and pg_indexes requests
child revision#bb5b06778070 [pkg] Prepare 1.13.0
files modified by this revision
test/unittest_db.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1417535380 -3600
# Tue Dec 02 16:49:40 2014 +0100
# Node ID fa3cb6e4777782aa30be51c64c1c801a0f122aaf
# Parent d9a772cdbb19f95e156fd45682ecd7f5eef89af8
[test] skip if we can't connect to a local mysql

http://dev.mysql.com/doc/refman/5.6/en/error-messages-client.html says
error code 2002 is the equivalent of 2003 for non-local instances.

diff --git a/test/unittest_db.py b/test/unittest_db.py
@@ -104,12 +104,13 @@
1              cnx = get_connection('mysql', self.host, database='', user='root',
2                                   quiet=1)
3          except  MySQLdb.OperationalError as ex:
4              if ex.args[0] == 1045: # find MysqlDb
5                  self.skipTest('mysql test requires a specific configuration')
6 -            elif ex.args[0] != 2003:
7 -                raise
8 +            elif ex.args[0] in (2002, 2003):
9 +                self.skipTest('could not connect to mysql')
10 +            raise
11 
12      def test_connection_wrap(self):
13          """Tests the connection wrapping"""
14          try:
15              import psycopg2