diff --git a/.travis.yml b/.travis.yml index a74090b2..f16c6582 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/requirements.txt b/requirements.txt index 42dd9ee6..121ba87f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 17375b1c..2be23b86 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -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: diff --git a/tox.ini b/tox.ini index cef3efc7..8306ccf2 100644 --- a/tox.ini +++ b/tox.ini @@ -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