Increase test parallelism

- Split out tests and add markers to control where they are run in Travis
- Run each marker on a separate Travis task
- Install pytest-xdist to increase parallelism inside each worker
- Set xdist parallelism to 3
This commit is contained in:
Bruno Alla 2019-05-15 12:37:17 +01:00
parent 4b2a62e889
commit a245651f66
4 changed files with 30 additions and 6 deletions

View File

@ -13,10 +13,14 @@ before_install:
matrix:
include:
- name: Tox Test
- name: Test results
script: tox -e py36
- name: Black template
- name: Run flake8 on result
script: tox -e flake8
- name: Run black on result
script: tox -e black
- name: Black template
script: tox -e black-template
- name: Basic Docker
script: sh tests/test_docker.sh
- name: Docker with Celery

View File

@ -13,4 +13,5 @@ tox==3.10.0
pytest==4.5.0
pytest_cases==1.6.2
pytest-cookies==0.3.0
pytest-xdist==1.28.0
pyyaml==5.1

View File

@ -101,9 +101,10 @@ def test_project_generation(cookies, context, context_combination):
check_paths(paths)
def test_linting_passes(cookies, context_combination):
@pytest.mark.flake8
def test_flake8_passes(cookies, context_combination):
"""
Generated project should pass flake8 & black.
Generated project should pass flake8.
This is parametrized for each combination from ``context_combination`` fixture
"""
@ -114,6 +115,16 @@ def test_linting_passes(cookies, context_combination):
except sh.ErrorReturnCode as e:
pytest.fail(e)
@pytest.mark.black
def test_black_passes(cookies, context_combination):
"""
Generated project should pass black.
This is parametrized for each combination from ``context_combination`` fixture
"""
result = cookies.bake(extra_context=context_combination)
try:
sh.black("--check", "--diff", "--exclude", "migrations", f"{result.project}/")
except sh.ErrorReturnCode as e:

12
tox.ini
View File

@ -1,11 +1,19 @@
[tox]
skipsdist = true
envlist = py36,black
envlist = py36,flake8,black,black-template
[testenv]
deps = -rrequirements.txt
commands = pytest {posargs:./tests}
commands = pytest -n 3 -m "not flake8" -m "not black" {posargs:./tests}
[testenv:flake8]
deps = -rrequirements.txt
commands = pytest -n 3 -m flake8 {posargs:./tests}
[testenv:black]
deps = -rrequirements.txt
commands = pytest -n 3 -m black {posargs:./tests}
[testenv:black-template]
deps = black
commands = black --check hooks tests setup.py docs