From 34c075e6f331d146a617417e646170e8847c39e4 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 13 Jan 2014 21:52:08 -0500 Subject: support --backend as a pytest flag to limit to one backend for testing --- tests/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index 693a0c8f..343f3efe 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -16,6 +16,16 @@ import os import pytest +def modify_backend_list(name, all_backends): + if name is not None: + backends = list(all_backends) + for backend in backends: + if backend.name != name: + all_backends.remove(backend) + if len(all_backends) == 0: + raise ValueError("No backends selected for testing") + + def check_for_iface(name, iface, item): if name in item.keywords and "backend" in item.funcargs: if not isinstance(item.funcargs["backend"], iface): -- cgit v1.2.3 From c421e636b15768e1adaf8bf681ecdd12b96c8669 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sat, 18 Jan 2014 09:22:21 -0600 Subject: modify backend selection to allow multiple backends via comma delimiter --- tests/utils.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index 343f3efe..ee1675e8 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -16,14 +16,23 @@ import os import pytest -def modify_backend_list(name, all_backends): - if name is not None: - backends = list(all_backends) - for backend in backends: - if backend.name != name: - all_backends.remove(backend) - if len(all_backends) == 0: - raise ValueError("No backends selected for testing") +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 + backends = list(backend_list) + for backend in backends: + if backend.name not in split_names: + backend_list.remove(backend) + + if len(backend_list) > 0: + return backend_list + else: + raise ValueError( + "No backend selected. Tried to select: {0}".format(split_names) + ) def check_for_iface(name, iface, item): -- cgit v1.2.3 From aed9e17b6080d540ba5b5aab5e3096581a4bbd13 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sun, 19 Jan 2014 12:09:27 -0600 Subject: revert fixture decorator for now, switch to append. no more globals --- tests/utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index ee1675e8..a2432256 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -22,13 +22,13 @@ def select_backends(names, 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 - backends = list(backend_list) - for backend in backends: - if backend.name not in split_names: - backend_list.remove(backend) + selected_backends = [] + for backend in backend_list: + if backend.name in split_names: + selected_backends.append(backend) - if len(backend_list) > 0: - return backend_list + if len(selected_backends) > 0: + return selected_backends else: raise ValueError( "No backend selected. Tried to select: {0}".format(split_names) -- cgit v1.2.3