Skip to content

Commit

Permalink
read docker host from env variable for OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
nickolai-dr committed May 22, 2016
1 parent 8fdd606 commit bca48eb
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions tests/conftest.py
Expand Up @@ -21,7 +21,16 @@ def session_id():

@pytest.fixture(scope='session')
def docker():
return DockerClient(version='auto')
if os.environ.get('DOCKER_MACHINE_IP') is not None:
docker = DockerClient.from_env(assert_hostname=False)
else:
docker = DockerClient(version='auto')
return docker


@pytest.fixture(scope='session')
def host():
return os.environ.get('DOCKER_MACHINE_IP', '127.0.0.1')


@pytest.fixture(scope='session')
Expand Down Expand Up @@ -62,7 +71,7 @@ def pg_params(pg_server):


@pytest.yield_fixture(scope='session')
def pg_server(unused_port, docker, session_id):
def pg_server(host, unused_port, docker, session_id):
pg_tag = '9.5'
docker.pull('postgres:{}'.format(pg_tag))
port = unused_port()
Expand All @@ -77,7 +86,7 @@ def pg_server(unused_port, docker, session_id):
pg_params = dict(database='postgres',
user='postgres',
password='mysecretpassword',
host='127.0.0.1',
host=host,
port=port)
delay = 0.001
dsn = create_pg_dsn(pg_params)
Expand Down Expand Up @@ -109,7 +118,7 @@ def mysql_params(mysql_server):


@pytest.yield_fixture(scope='session')
def mysql_server(unused_port, docker, session_id):
def mysql_server(host, unused_port, docker, session_id):
mysql_tag = '5.7'
docker.pull('mysql:{}'.format(mysql_tag))
port = unused_port()
Expand All @@ -128,7 +137,7 @@ def mysql_server(unused_port, docker, session_id):
mysql_params = dict(database='aioodbc',
user='aioodbc',
password='mysecretpassword',
host='127.0.0.1',
host=host,
port=port)
delay = 0.001
dsn = create_mysql_dsn(mysql_params)
Expand Down

0 comments on commit bca48eb

Please sign in to comment.