File: conftest.py

package info (click to toggle)
python-binary-memcached 0.31.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 304 kB
  • sloc: python: 1,722; makefile: 17
file content (43 lines) | stat: -rw-r--r-- 890 bytes parent folder | download | duplicates (3)
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()