| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
import functools |
| 17 |
|
| 18 |
from oslo_utils import reflection |
| 19 |
|
| 20 |
|
| 21 |
ALLOWED_DIALECTS = ['sqlite', 'mysql', 'postgresql'] |
| 22 |
|
| 23 |
|
| 24 |
def backend_specific(*dialects): |
| 25 |
"""Decorator to skip backend specific tests on inappropriate engines. |
| 26 |
|
| 27 |
::dialects: list of dialects names under which the test will be launched. |
| 28 |
""" |
| 29 |
def wrap(f): |
| 30 |
@functools.wraps(f) |
| 31 |
def ins_wrap(self): |
| 32 |
if not set(dialects).issubset(ALLOWED_DIALECTS): |
| 33 |
raise ValueError( |
| 34 |
"Please use allowed dialects: %s" % ALLOWED_DIALECTS) |
| 35 |
if self.engine.name not in dialects: |
| 36 |
msg = ('The test "%s" can be run ' |
| 37 |
'only on %s. Current engine is %s.') |
| 38 |
args = (reflection.get_callable_name(f), ', '.join(dialects), |
| 39 |
self.engine.name) |
| 40 |
self.skipTest(msg % args) |
| 41 |
else: |
| 42 |
return f(self) |
| 43 |
return ins_wrap |
| 44 |
return wrap |