summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSviatoslav Sydorenko <wk@sydorenko.org.ua>2018-09-10 02:00:10 +0200
committerSviatoslav Sydorenko <wk@sydorenko.org.ua>2018-09-10 02:00:10 +0200
commitb9c87597d729e99af5f7809fdcae3f9588ae2f5f (patch)
treea15fc7bbf77ba7cef78df246c8b6cd0451883313
parent979e3a765b7b237b8a5f23b0393971429a1881e9 (diff)
downloadcherrypy-git-b9c87597d729e99af5f7809fdcae3f9588ae2f5f.tar.gz
Revert "Use UNIX-socket based memcached connection"
This reverts commit 471ae664021fd282217d2e0ed607a697fb01ece6.
-rwxr-xr-xcherrypy/test/test_session.py34
1 files changed, 29 insertions, 5 deletions
diff --git a/cherrypy/test/test_session.py b/cherrypy/test/test_session.py
index f3d47ba0..df06e45d 100755
--- a/cherrypy/test/test_session.py
+++ b/cherrypy/test/test_session.py
@@ -8,6 +8,7 @@ from distutils.spawn import find_executable
import pytest
from path import Path
from more_itertools import consume
+import portend
import cherrypy
from cherrypy._cpcompat import HTTPSConnection
@@ -406,7 +407,7 @@ def is_memcached_present():
return bool(executable)
-@pytest.fixture()
+@pytest.fixture(scope='session')
def memcached_server_present():
is_memcached_present() or pytest.skip('memcached not available')
@@ -416,14 +417,37 @@ def memcached_client_present():
pytest.importorskip('memcache')
+@pytest.fixture(scope='session')
+def memcached_instance(request, watcher_getter, memcached_server_present):
+ """
+ Start up an instance of memcached.
+ """
+
+ port = portend.find_available_local_port()
+
+ def is_occupied():
+ try:
+ portend.Checker().assert_free('localhost', port)
+ except Exception:
+ return True
+ return False
+
+ proc = watcher_getter(
+ name='memcached',
+ arguments=['-p', str(port)],
+ checker=is_occupied,
+ request=request,
+ )
+ return locals()
+
+
@pytest.fixture
-@pytest.mark.usefixtures('memcached_client_present')
-@pytest.mark.usefixtures('memcached_server_present')
-def memcached_configured(memcached_connection, monkeypatch):
+def memcached_configured(memcached_instance, monkeypatch, memcached_client_present):
+ server = 'localhost:{port}'.format_map(memcached_instance)
monkeypatch.setattr(
sessions.MemcachedSession,
'servers',
- [memcached_connection],
+ [server],
)