-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
37 lines (26 loc) · 854 Bytes
/
conftest.py
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
import argparse
import os
import pytest
def pgtype_check(value):
types = ('native', 'docker')
if value not in types:
raise argparse.ArgumentTypeError('Must be one of %s' % str(types))
if value == 'docker':
try:
import docker
client = docker.from_env()
client.version()
except: # noqa
raise argparse.ArgumentTypeError('Docker is not running')
return value
def pytest_addoption(parser):
parser.addoption(
'--pgtype', type=pgtype_check, action='store', default='native',
help='Postgrey server type: native or docker. Default: %(default)s'
)
@pytest.fixture
def pgtype(request):
return request.config.getoption('--pgtype')
@pytest.fixture
def dockerfile():
return os.path.join(os.path.dirname(__file__), 'docker', 'postgrey')