summaryrefslogtreecommitdiff
path: root/testing/tests
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2017-09-09 15:31:49 -0300
committerVictor Shyba <victor1984@riseup.net>2017-09-11 16:24:30 -0300
commit89dd40d77fbd602a415e5ae673d4166e1b432428 (patch)
treeb6982a2ea42ff6842ff1cf54dcd320cdde368e05 /testing/tests
parent8e6cddf794c4b0e44bec6daa4363f2926e238f0a (diff)
[test] selectivelly start events server on benchmarks
Soledad's events server might be a pain for tests because if it is not properly initialized and shut down there might be parts of the server missing or leftover in the reactor after tests are run. With the recent changes to the way tests are invocated, there's the need to further isolate events server startup for benchmarks, otherwise it will conflict with other tests. This commit moves the events server setup to inside the pytest_collection_modifyitems() hook, where we can check if the benchmark subdir was selected and properly start the events server if needed.
Diffstat (limited to 'testing/tests')
-rw-r--r--testing/tests/benchmarks/conftest.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/testing/tests/benchmarks/conftest.py b/testing/tests/benchmarks/conftest.py
index 377fc606..80eccb08 100644
--- a/testing/tests/benchmarks/conftest.py
+++ b/testing/tests/benchmarks/conftest.py
@@ -9,19 +9,12 @@ import time
from twisted.internet import threads, reactor
-# we have to manually setup the events server in order to be able to signal
-# events. This is usually done by the enclosing application using soledad
-# client (i.e. bitmask client).
-from leap.common.events import server
-server.ensure_server()
-
-
#
# pytest customizations
#
# mark benchmark tests using their group names (thanks ionelmc! :)
-def pytest_collection_modifyitems(items):
+def pytest_collection_modifyitems(items, config):
for item in items:
bench = item.get_marker("benchmark")
if bench and bench.kwargs.get('group'):
@@ -29,6 +22,14 @@ def pytest_collection_modifyitems(items):
marker = getattr(pytest.mark, 'benchmark_' + group)
item.add_marker(marker)
+ subdir = config.getoption('subdir')
+ if subdir == 'benchmarks':
+ # we have to manually setup the events server in order to be able to
+ # signal events. This is usually done by the enclosing application
+ # using soledad client (i.e. bitmask client).
+ from leap.common.events import server
+ server.ensure_server()
+
#
# benchmark fixtures