Test all possible template combinations in flake8 tests

This commit is contained in:
Bruno Alla 2019-03-25 18:29:37 +00:00
parent b91c70d755
commit 346b216c55

View File

@ -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))