Skip to content

Commit 6d5551c

Browse files
authored
Fix CI builds (#26)
* extract mysql_base_dir to a configuration fixture * add workaround for travis mysql * Resolve some pep8 issues * Use pytest-pep8 instead of pytest-pylama * Remove tags for unsupported python versions * Do not use deprecated functions * Revamp tox/travis configuration * Fix linters not being run in travis * Remove unused code * Fix coverage not collecting results correctly * Enable branch coverage
1 parent e7343ce commit 6d5551c

File tree

7 files changed

+78
-61
lines changed

7 files changed

+78
-61
lines changed

.travis.yml

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
11
sudo: false
22
language: python
3-
python: "3.4"
4-
env:
5-
matrix:
6-
- TESTENV=linters
7-
- TESTENV=py27
8-
- TESTENV=py27-xdist
9-
- TESTENV=py27-pytest-latest
10-
- TESTENV=py34
11-
- TESTENV=coveralls
12-
install:
13-
- pip install tox
14-
script: tox -e $TESTENV
3+
python: "2.7"
4+
5+
matrix:
6+
include:
7+
- env: TOXENV=linters
8+
- env: TOXENV=py27-pytest30
9+
- env: TOXENV=py27-pytest31
10+
- env: TOXENV=py27-pytest32
11+
- env: TOXENV=py27-pytest33
12+
- env: TOXENV=py27-pytest34
13+
- env: TOXENV=py27-pytest35
14+
- env: TOXENV=py27-pytest36
15+
- env: TOXENV=py27-pytest37
16+
- env: TOXENV=py27-pytest38
17+
- env: TOXENV=py27-pytest39
18+
- env: TOXENV=py27-pytest310
19+
- env: TOXENV=py27-pytestlatest
20+
- env: TOXENV=py27-pytestlatest-xdist
21+
- env: TOXENV=py34-pytestlatest
22+
python: "3.4"
23+
- env: TOXENV=py35-pytestlatest
24+
python: "3.5"
25+
- env: TOXENV=py36-pytestlatest
26+
python: "3.6"
27+
- env: TOXENV=py27-pytestlatest-coveralls
28+
install: pip install tox
29+
# mysql_install_db will not work if it can't find the my-default.cnf file
30+
before_script: sudo cp /etc/mysql/my.cnf /usr/share/mysql/my-default.cnf
31+
script: tox
1532
branches:
1633
except:
17-
- /^\d/
34+
- /^\d/
1835
notifications:
1936
email:
2037

pytest_services/mysql.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,35 @@ def mysql_defaults_file(run_services, mysql_data_dir, memory_temp_dir):
2828

2929

3030
@pytest.fixture(scope='session')
31-
def mysql_system_database(run_services, mysql_data_dir, mysql_defaults_file, memory_temp_dir, lock_dir, services_log):
31+
def mysql_base_dir():
32+
my_print_defaults = find_executable('my_print_defaults')
33+
assert my_print_defaults, 'You have to install my_print_defaults script.'
34+
35+
return os.path.dirname(os.path.dirname(os.path.realpath(my_print_defaults)))
36+
37+
38+
@pytest.fixture(scope='session')
39+
def mysql_system_database(
40+
run_services,
41+
mysql_data_dir,
42+
mysql_base_dir,
43+
mysql_defaults_file,
44+
memory_temp_dir,
45+
lock_dir,
46+
services_log,
47+
):
3248
"""Install database to given path."""
3349
if run_services:
3450
mysql_install_db = find_executable('mysql_install_db')
3551
assert mysql_install_db, 'You have to install mysql_install_db script.'
3652

37-
my_print_defaults = find_executable('my_print_defaults')
38-
assert my_print_defaults, 'You have to install my_print_defaults script.'
39-
40-
mysql_basedir = os.path.dirname(os.path.dirname(os.path.realpath(my_print_defaults)))
41-
4253
try:
4354
services_log.debug('Starting mysql_install_db.')
4455
check_output([
4556
mysql_install_db,
4657
'--defaults-file={0}'.format(mysql_defaults_file),
4758
'--datadir={0}'.format(mysql_data_dir),
48-
'--basedir={0}'.format(mysql_basedir),
59+
'--basedir={0}'.format(mysql_base_dir),
4960
'--user={0}'.format(os.environ['USER'])
5061
])
5162
except CalledProcessWithOutputError as e:

pytest_services/service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ def watcher_getter(request, services_log):
5858
Add finalizer to properly stop it.
5959
"""
6060
orig_request = request
61+
6162
def watcher_getter_function(name, arguments=None, kwargs=None, timeout=20, checker=None, request=None):
6263
if request is None:
63-
warnings.warn('Omitting the `request` parameter will result in an '
64-
'unstable order of finalizers.')
64+
warnings.warn('Omitting the `request` parameter will result in an unstable order of finalizers.')
6565
request = orig_request
6666
executable = find_executable(name)
6767
assert executable, 'You have to install {0} executable.'.format(name)

requirements-testing.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ mock
44
mysqlclient
55
pylibmc
66
pytest-pep8
7-
pylama
8-
pylama_pylint
97
astroid

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
'Topic :: Utilities',
5353
'Programming Language :: Python :: 2',
5454
'Programming Language :: Python :: 3',
55-
] + [('Programming Language :: Python :: %s' % x) for x in '2.7 3.0 3.1 3.2 3.3 3.4'.split()],
55+
] + [('Programming Language :: Python :: %s' % x) for x in '2.7 3.4 3.5 3.6 3.7'.split()],
5656
tests_require=['tox'],
5757
entry_points={'pytest11': [
5858
'pytest-services=pytest_services.plugin',

tests/test_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_memcached(request, memcached, memcached_socket):
1313
assert mc.get('some') == 1
1414

1515
# check memcached cleaner
16-
request.getfuncargvalue('memcached_clean')
16+
request.getfixturevalue('memcached_clean')
1717
assert mc.get('some') is None
1818

1919

tox.ini

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,50 @@
11
[tox]
22
distshare={homedir}/.tox/distshare
3-
envlist=linters,py27,py27-xdist,py27-pytest-latest,py34
3+
envlist=
4+
linters
5+
py27-pytest{30,31,32,33,34,35,36,37,38,39,310,latest}
6+
py{34,35,36}-pytestlatest
7+
py27-pytestlatest-xdist
8+
py27-pytestlatest-coveralls
49
skip_missing_interpreters = true
510

611
[testenv]
712
commands= py.test tests --junitxml={envlogdir}/junit-{envname}.xml
813
deps =
9-
-e.
14+
pytestlatest: pytest
15+
pytest310: pytest~=3.10.0
16+
pytest39: pytest~=3.9.0
17+
pytest38: pytest~=3.8.0
18+
pytest37: pytest~=3.7.0
19+
pytest36: pytest~=3.6.0
20+
pytest35: pytest~=3.5.0
21+
pytest34: pytest~=3.4.0
22+
pytest33: pytest~=3.3.0
23+
pytest32: pytest~=3.2.0
24+
pytest31: pytest~=3.1.0
25+
pytest30: pytest~=3.0.0
26+
xdist: pytest-xdist
1027
-r{toxinidir}/requirements-testing.txt
1128
passenv = DISPLAY COVERALLS_REPO_TOKEN USER TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
1229
extras = memcache
1330

1431
[testenv:linters]
1532
basepython=python2.7
16-
commands={[testenv]commands} pytest_services --pylama
33+
commands={[testenv]commands} pytest_services --pep8 -m pep8
1734

18-
[testenv:coveralls]
35+
[testenv:py27-pytestlatest-coveralls]
36+
usedevelop = True
1937
deps =
2038
{[testenv]deps}
2139
coveralls
2240
commands=
23-
coverage run --source=pytest_services {envdir}/bin/py.test tests
41+
coverage run --source=pytest_services --branch -m pytest tests
2442
coverage report -m
2543
coveralls
2644

27-
[testenv:py27-xdist]
28-
basepython=python2.7
29-
deps =
30-
{[testenv]deps}
31-
pytest-xdist
32-
commands=
33-
py.test tests -n1 -rfsxX \
34-
--junitxml={envlogdir}/junit-{envname}.xml
35-
36-
[testenv:py27-pytest-latest]
37-
basepython=python2.7
38-
deps =
39-
{[testenv]deps}
40-
git+https://github.com/pytest-dev/py.git@master#egg=py
41-
git+https://github.com/pytest-dev/pytest.git@features#egg=pytest
45+
[testenv:py27-pytestlatest-xdist]
46+
commands={[testenv]commands} -n1 -rfsxX
4247

4348
[pytest]
49+
pep8maxlinelength=120
4450
addopts = -vvl
45-
46-
[pylama]
47-
format = pep8
48-
skip = */.tox/*,*/.env/*
49-
linters = pylint,mccabe,pep8,pep257
50-
ignore = F0401,C0111,E731,D100,W0621,W0108,R0201,W0401,W0614,W0212,C901,R0914,I0011,D211
51-
52-
[pylama:pep8]
53-
max_line_length = 120
54-
55-
[pylama:pylint]
56-
max_line_length = 120
57-
58-
[pylama:mccabe]
59-
max_complexity = 11

0 commit comments

Comments
 (0)