test: flush all records between pytest tests
This commit is contained in:
parent
d29425fb2e
commit
d2b7987ac3
|
@ -8,6 +8,7 @@ from threading import Thread
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def dragonfly_db():
|
def dragonfly_db():
|
||||||
|
""" Starts a single DragonflyDB process, runs only once. """
|
||||||
dragonfly_path = os.environ.get("DRAGONFLY_HOME", '../../build-dbg/dragonfly')
|
dragonfly_path = os.environ.get("DRAGONFLY_HOME", '../../build-dbg/dragonfly')
|
||||||
print("Starting DragonflyDB [{}]".format(dragonfly_path))
|
print("Starting DragonflyDB [{}]".format(dragonfly_path))
|
||||||
# TODO: parse arguments and pass them over
|
# TODO: parse arguments and pass them over
|
||||||
|
@ -19,7 +20,7 @@ def dragonfly_db():
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
print("Terminating DragonflyDB process [{}]".format(p.id))
|
print("Terminating DragonflyDB process [{}]".format(p.pid))
|
||||||
try:
|
try:
|
||||||
p.terminate()
|
p.terminate()
|
||||||
outs, errs = p.communicate(timeout=15)
|
outs, errs = p.communicate(timeout=15)
|
||||||
|
@ -31,12 +32,19 @@ def dragonfly_db():
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def client(dragonfly_db):
|
def connection(dragonfly_db):
|
||||||
pool = redis.ConnectionPool(decode_responses=True)
|
pool = redis.ConnectionPool(decode_responses=True)
|
||||||
client = redis.Redis(connection_pool=pool)
|
client = redis.Redis(connection_pool=pool)
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def client(connection):
|
||||||
|
""" Flushes all the records, runs before each test. """
|
||||||
|
connection.flushall()
|
||||||
|
return connection
|
||||||
|
|
||||||
|
|
||||||
class BLPopWorkerThread:
|
class BLPopWorkerThread:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.result = None
|
self.result = None
|
||||||
|
|
Loading…
Reference in New Issue