diff options
Diffstat (limited to 'tests/utils.py')
-rw-r--r-- | tests/utils.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/utils.py b/tests/utils.py index 693a0c8f..a2432256 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -16,6 +16,25 @@ import os import pytest +def select_backends(names, backend_list): + if names is None: + return backend_list + split_names = [x.strip() for x in names.split(',')] + # this must be duplicated and then removed to preserve the metadata + # pytest associates. Appending backends to a new list doesn't seem to work + selected_backends = [] + for backend in backend_list: + if backend.name in split_names: + selected_backends.append(backend) + + if len(selected_backends) > 0: + return selected_backends + else: + raise ValueError( + "No backend selected. Tried to select: {0}".format(split_names) + ) + + def check_for_iface(name, iface, item): if name in item.keywords and "backend" in item.funcargs: if not isinstance(item.funcargs["backend"], iface): |