From e5ab943f8ccf8f4abcac018b88c8f151da7a12bb Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Mon, 14 Oct 2019 12:59:22 +0100 Subject: [PATCH] Adds conftest and defines session fixtures --- test/unit/conftest.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/unit/conftest.py diff --git a/test/unit/conftest.py b/test/unit/conftest.py new file mode 100644 index 0000000..361e99f --- /dev/null +++ b/test/unit/conftest.py @@ -0,0 +1,30 @@ +import pytest +from time import sleep +from threading import Thread +from multiprocessing import Process + +from pisa.api import start_api +from test.simulator.bitcoind_sim import run_simulator + +bitcoind_process = Process(target=run_simulator) + + +@pytest.fixture(autouse=True, scope='session') +def run_bitcoind(): + global bitcoind_process + + bitcoind_process.daemon = True + bitcoind_process.start() + + # It takes a little bit of time to start the API (otherwise the requests are sent too early and they fail) + sleep(0.1) + + +@pytest.fixture(autouse=True, scope='session') +def run_api(): + api_thread = Thread(target=start_api) + api_thread.daemon = True + api_thread.start() + + # It takes a little bit of time to start the API (otherwise the requests are sent too early and they fail) + sleep(0.1)