-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
26 lines (19 loc) · 716 Bytes
/
conftest.py
File metadata and controls
26 lines (19 loc) · 716 Bytes
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
import logging
from subprocess import Popen, PIPE
from time import sleep
import pytest
def pytest_addoption(parser):
parser.addoption("--pypath", action="store", default="python", help="Path to python interpreter in the venv")
@pytest.fixture(scope='session')
def pypath(request):
pypath = request.config.getoption("--pypath")
logging.info(f'Python path is: {pypath}')
return request.config.getoption("--pypath")
@pytest.fixture(scope='session')
def http_server(pypath):
logging.info('Starting server...')
server = Popen([pypath, 'api_server.py'], stdout=PIPE, stderr=PIPE)
sleep(1) # Wait for server to start up
yield
logging.info('Stopping server...')
server.kill()