Move exception trapping to the right place
@@ -401,19 +401,12 @@ class SessionTest(helper.CPWebCase):
@pytest.fixture(scope='session')
-def memcached_instance(request):
+def memcached_instance(request, watcher_getter):
"""
Start up an instance of memcached.
"""
pytest.importorskip('memcache')
- try:
- watcher_getter = request.getfixturevalue('watcher_getter')
- except AssertionError as err:
- if str(err) != 'You have to install memcached executable.':
- raise
- pytest.skip('memcached not available')
-
port = portend.find_available_local_port()
def is_occupied():
@@ -423,12 +416,18 @@ def memcached_instance(request):
return True
return False
+ try:
proc = watcher_getter(
name='memcached',
arguments=['-p', str(port)],
checker=is_occupied,
request=request,
)
+ except AssertionError as err:
+ if str(err) != 'You have to install memcached executable.':
+ raise
+ pytest.skip('memcached not available')
+ else:
return locals()
