diff options
author | Sviatoslav Sydorenko <wk@sydorenko.org.ua> | 2018-09-10 01:27:46 +0200 |
---|---|---|
committer | Sviatoslav Sydorenko <wk@sydorenko.org.ua> | 2018-09-10 01:27:46 +0200 |
commit | 471ae664021fd282217d2e0ed607a697fb01ece6 (patch) | |
tree | b0dd6acfd60255d85f13b9b8f1db0072e71abf6c | |
parent | 02e53a941114297f537e3dff3f9532e2f9a6779b (diff) | |
download | cherrypy-git-471ae664021fd282217d2e0ed607a697fb01ece6.tar.gz |
Use UNIX-socket based memcached connection
-rwxr-xr-x | cherrypy/test/test_session.py | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/cherrypy/test/test_session.py b/cherrypy/test/test_session.py index 9cd06c9b..f3d47ba0 100755 --- a/cherrypy/test/test_session.py +++ b/cherrypy/test/test_session.py @@ -8,7 +8,6 @@ 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 @@ -408,42 +407,23 @@ def is_memcached_present(): @pytest.fixture() -def memcached_client_present(): - pytest.importorskip('memcache') - - -@pytest.fixture(scope='session') -def memcached_instance(request, watcher_getter): - """ - Start up an instance of memcached. - """ +def memcached_server_present(): is_memcached_present() or pytest.skip('memcached not available') - 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() +def memcached_client_present(): + pytest.importorskip('memcache') @pytest.fixture -def memcached_configured(memcached_instance, monkeypatch): - server = 'localhost:{port}'.format_map(memcached_instance) +@pytest.mark.usefixtures('memcached_client_present') +@pytest.mark.usefixtures('memcached_server_present') +def memcached_configured(memcached_connection, monkeypatch): monkeypatch.setattr( sessions.MemcachedSession, 'servers', - [server], + [memcached_connection], ) @@ -451,7 +431,6 @@ def memcached_configured(memcached_instance, monkeypatch): platform.system() == 'Windows', reason='pytest-services helper does not work under Windows', ) -@pytest.mark.usefixtures('memcached_client_present') @pytest.mark.usefixtures('memcached_configured') class MemcachedSessionTest(helper.CPWebCase): setup_server = staticmethod(setup_server) |