Skip to content

Commit 450b25b

Browse files
committed
Attempted to move db completely to docker
1 parent c4cdc1b commit 450b25b

File tree

2 files changed

+42
-30
lines changed

2 files changed

+42
-30
lines changed

.travis.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: python
22

33
python:
4-
- 3.5.3
54
- 3.6
65

76
env:
@@ -15,23 +14,33 @@ services:
1514
matrix:
1615
include:
1716
- python: 3.6
18-
env: PYTHONASYNCIODEBUG=
19-
addons:
20-
mariadb: '5.5'
17+
env:
18+
- PYTHONASYNCIODEBUG=
19+
- DB=mariadb
20+
- DBTAG=5.5
2121
- python: 3.6
22-
env: PYTHONASYNCIODEBUG=1
22+
env:
23+
- PYTHONASYNCIODEBUG=1
24+
- DB=mariadb
25+
- DBTAG=10.0
2326
addons:
2427
mariadb: '10.0'
2528
- python: 3.6
26-
env: PYTHONASYNCIODEBUG=
27-
addons:
28-
mariadb: '10.1'
29+
env:
30+
- PYTHONASYNCIODEBUG=
31+
- DB=mariadb
32+
- DBTAG=10.5
33+
- python: 3.6
34+
env:
35+
- PYTHONASYNCIODEBUG=
36+
- DB=mysql
37+
- DBTAG=5.7
2938

3039

31-
before_script:
32-
- "mysql -e 'SELECT VERSION()'"
33-
- "mysql -e 'DROP DATABASE IF EXISTS test_pymysql; create database test_pymysql DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"
34-
- "mysql -e 'DROP DATABASE IF EXISTS test_pymysql2; create database test_pymysql2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"
40+
#before_script:
41+
# - "mysql -e 'SELECT VERSION()'"
42+
# - "mysql -e 'DROP DATABASE IF EXISTS test_pymysql; create database test_pymysql DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"
43+
# - "mysql -e 'DROP DATABASE IF EXISTS test_pymysql2; create database test_pymysql2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"
3544

3645
install:
3746
- pip install -Ur requirements-dev.txt

tests/conftest.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,27 @@ def pytest_generate_tests(metafunc):
3434
if 'loop_type' in metafunc.fixturenames:
3535
loop_type = ['asyncio', 'uvloop'] if uvloop else ['asyncio']
3636
metafunc.parametrize("loop_type", loop_type)
37-
38-
if 'mysql_tag' in metafunc.fixturenames:
39-
tags = set(metafunc.config.option.mysql_tag)
40-
if not tags:
41-
tags = ['5.6', '8.0']
42-
elif 'all' in tags:
43-
tags = ['5.6', '5.7', '8.0']
44-
else:
45-
tags = list(tags)
46-
metafunc.parametrize("mysql_tag", tags, scope='session')
37+
#
38+
# if 'mysql_tag' in metafunc.fixturenames:
39+
# tags = set(metafunc.config.option.mysql_tag)
40+
# if not tags:
41+
# tags = ['5.6', '8.0']
42+
# elif 'all' in tags:
43+
# tags = ['5.6', '5.7', '8.0']
44+
# else:
45+
# tags = list(tags)
46+
# metafunc.parametrize("mysql_tag", tags, scope='session')
4747

4848

4949
# This is here unless someone fixes the generate_tests bit
5050
@pytest.yield_fixture(scope='session')
5151
def mysql_tag():
52-
return '5.6'
52+
return os.environ.get('DBTAG', '10.5')
53+
54+
55+
@pytest.yield_fixture(scope='session')
56+
def mysql_image():
57+
return os.environ.get('DB', 'mariadb')
5358

5459

5560
@pytest.yield_fixture
@@ -119,12 +124,10 @@ def pytest_addoption(parser):
119124

120125

121126
@pytest.fixture
122-
def mysql_params():
123-
params = {"host": os.environ.get('MYSQL_HOST', 'localhost'),
124-
"port": int(os.environ.get('MYSQL_PORT', 3306)),
125-
"user": os.environ.get('MYSQL_USER', 'root'),
127+
def mysql_params(mysql_server):
128+
params = {**mysql_server['conn_params'],
126129
"db": os.environ.get('MYSQL_DB', 'test_pymysql'),
127-
"password": os.environ.get('MYSQL_PASSWORD', ''),
130+
# "password": os.environ.get('MYSQL_PASSWORD', ''),
128131
"local_infile": True,
129132
"use_unicode": True,
130133
}
@@ -227,11 +230,11 @@ def ensure_mysql_verison(request, mysql_tag):
227230

228231

229232
@pytest.fixture(scope='session')
230-
def mysql_server(unused_port, docker, session_id, mysql_tag, request):
233+
def mysql_server(unused_port, docker, session_id, mysql_image, mysql_tag, request):
231234
print('\nSTARTUP CONTAINER - {0}\n'.format(mysql_tag))
232235

233236
if not request.config.option.no_pull:
234-
docker.pull('mysql:{}'.format(mysql_tag))
237+
docker.pull('{}:{}'.format(mysql_image, mysql_tag))
235238

236239
# bound IPs do not work on OSX
237240
host = "127.0.0.1"

0 commit comments

Comments
 (0)