From 346b216c555ac3500c8cad9415ef7b05e823d9fb Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 25 Mar 2019 18:29:37 +0000 Subject: [PATCH] Test all possible template combinations in flake8 tests --- tests/test_cookiecutter_generation.py | 58 +++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 3010d364f..a3f4825b1 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -1,14 +1,17 @@ import os import re -import sh -import yaml import pytest +import sh +import yaml from binaryornot.check import is_binary PATTERN = "{{(\s?cookiecutter)[.](.*?)}}" RE_OBJ = re.compile(PATTERN) +BINARY_CHOICES = ["y", "n"] +JS_TASK_RUNNER_CHOICES = ["None", "Gulp"] + @pytest.fixture def context(): @@ -78,9 +81,56 @@ def test_enabled_features(cookies, feature_context): check_paths(paths) -def test_flake8_compliance(cookies): +@pytest.mark.parametrize("windows", BINARY_CHOICES) +@pytest.mark.parametrize("use_pycharm", BINARY_CHOICES) +@pytest.mark.parametrize("use_docker", BINARY_CHOICES) +@pytest.mark.parametrize("js_task_runner", JS_TASK_RUNNER_CHOICES) +@pytest.mark.parametrize("custom_bootstrap_compilation", BINARY_CHOICES) +@pytest.mark.parametrize("use_celery", BINARY_CHOICES) +@pytest.mark.parametrize("use_mailhog", BINARY_CHOICES) +@pytest.mark.parametrize("use_sentry", BINARY_CHOICES) +@pytest.mark.parametrize( + # These 2 cannot be used together, but test the other combinations + ["use_compressor", "use_whitenoise"], + [("y", "n"), ("n", "n"), ("n", "n")], +) +@pytest.mark.parametrize("use_heroku", BINARY_CHOICES) +@pytest.mark.parametrize("use_travisci", BINARY_CHOICES) +@pytest.mark.parametrize("keep_local_envs_in_vcs", BINARY_CHOICES) +def test_flake8_compliance( + cookies, + windows, + use_pycharm, + use_docker, + js_task_runner, + custom_bootstrap_compilation, + use_celery, + use_mailhog, + use_sentry, + use_compressor, + use_whitenoise, + use_heroku, + use_travisci, + keep_local_envs_in_vcs, +): """generated project should pass flake8""" - result = cookies.bake() + result = cookies.bake( + extra_context={ + "windows": windows, + "use_pycharm": use_pycharm, + "use_docker": use_docker, + "js_task_runner": js_task_runner, + "custom_bootstrap_compilation": custom_bootstrap_compilation, + "use_compressor": use_compressor, + "use_celery": use_celery, + "use_mailhog": use_mailhog, + "use_sentry": use_sentry, + "use_whitenoise": use_whitenoise, + "use_heroku": use_heroku, + "use_travisci": use_travisci, + "keep_local_envs_in_vcs": keep_local_envs_in_vcs, + } + ) try: sh.flake8(str(result.project))