importorskip isn't a marker... so use the skipif marker.
import os
import threading
import time
-import socket
+import importlib
from http.client import HTTPConnection
import pytest
@@ -442,8 +442,19 @@ def memcached_configured(memcached_instance, monkeypatch):
)
+def importable(mod_name):
+ try:
+ importlib.import_module(mod_name)
+ except Exception:
+ return False
+ return True
+
+
@pytest.mark.usefixtures('memcached_configured')
-@pytest.mark.importorskip('memcache')
+@pytest.mark.skipif(
+ not importable('memcache'),
+ reason='Python memcache module unavailable',
+)
class MemcachedSessionTest(helper.CPWebCase):
setup_server = staticmethod(setup_server)
