aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utils.py
diff options
context:
space:
mode:
authorDavid Reid <dreid@dreid.org>2014-01-20 10:14:40 -0800
committerDavid Reid <dreid@dreid.org>2014-01-20 10:14:40 -0800
commitcd10571261ad24dcd0dc63c9703289faccd841a8 (patch)
tree5994b0a095af99749e05ee936f8932af9a86ff40 /tests/utils.py
parent580e992dc0d95618d3e667e471dd1d6a7eb6e323 (diff)
parentad4f646e685beb38e597bab83ea8e8314a3fd581 (diff)
downloadcryptography-cd10571261ad24dcd0dc63c9703289faccd841a8.tar.gz
cryptography-cd10571261ad24dcd0dc63c9703289faccd841a8.tar.bz2
cryptography-cd10571261ad24dcd0dc63c9703289faccd841a8.zip
Merge pull request #468 from reaperhulk/backend-flag-pytest
Add backend flag for pytest runs
Diffstat (limited to 'tests/utils.py')
-rw-r--r--tests/utils.py19
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):