mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 14:14:22 +01:00
bitcoin_cli as a global variable in the main __init__.py was creating issues related to http.client.CannotSendRequest: Request-sent and connection re-usage. Define a new connection per request.
27 lines
719 B
Python
27 lines
719 B
Python
import pytest
|
|
from time import sleep
|
|
from threading import Thread
|
|
|
|
from pisa.api import start_api
|
|
from test2.simulator.bitcoind_sim import run_simulator
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
def run_bitcoind():
|
|
bitcoind_thread = Thread(target=run_simulator)
|
|
bitcoind_thread.daemon = True
|
|
bitcoind_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)
|
|
|
|
|
|
@pytest.fixture(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)
|