[PATCH 06 of 10 logilab-database] [test] Handle possible absence of mysql support in test_funcname_with_different_backend_names

Denis Laxalde denis.laxalde at logilab.fr
Mon Jun 4 12:00:21 CEST 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1528102665 -7200
#      Mon Jun 04 10:57:45 2018 +0200
# Node ID a53d453a0b82866e7ce95d87fa2a819ec5862353
# Parent  709de493f9fedbaef1abd2206bad908438cfce4f
# Available At https://hg.logilab.org/review/logilab/database
#              hg pull https://hg.logilab.org/review/logilab/database -r a53d453a0b82
# EXP-Topic py3
[test] Handle possible absence of mysql support in test_funcname_with_different_backend_names

diff --git a/test/unittest_db.py b/test/unittest_db.py
--- a/test/unittest_db.py
+++ b/test/unittest_db.py
@@ -201,11 +201,15 @@ class DBAPIAdaptersTC(unittest.TestCase)
         register_function(MYFUNC)
 
         pghelper = get_db_helper('postgres')
-        mshelper = get_db_helper('mysql')
+        try:
+            mshelper = get_db_helper('mysql')
+        except ImportError:
+            mshelper = None
         slhelper = get_db_helper('sqlite')
         self.assertEqual(slhelper.func_as_sql('MYFUNC', ()), 'SQLITE_MYFUNC()')
         self.assertEqual(pghelper.func_as_sql('MYFUNC', ('foo',)), 'MYFUNC(foo)')
-        self.assertEqual(mshelper.func_as_sql('MYFUNC', ('foo', 'bar')), 'MYF(foo, bar)')
+        if mshelper is not None:
+            self.assertEqual(mshelper.func_as_sql('MYFUNC', ('foo', 'bar')), 'MYF(foo, bar)')
 
 class BaseSqlServer(unittest.TestCase):
     def tearDown(self):


More information about the cubicweb-devel mailing list