1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
import os
import subprocess
import time
import pytest
os.environ.setdefault("MEMCACHED_HOST", "localhost")
@pytest.yield_fixture(scope="session", autouse=True)
def memcached_standard_port():
p = subprocess.Popen(
["memcached"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
time.sleep(0.1)
yield p
p.kill()
p.wait()
@pytest.yield_fixture(scope="session", autouse=True)
def memcached_other_port():
p = subprocess.Popen(
["memcached", "-p5000"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
time.sleep(0.1)
yield p
p.kill()
p.wait()
@pytest.yield_fixture(scope="session", autouse=True)
def memcached_socket():
p = subprocess.Popen(
["memcached", "-s/tmp/memcached.sock"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
time.sleep(0.1)
yield p
p.kill()
p.wait()
|