From e9b18d08484cfa1c6e8bcb521041e54d65a5a4b8 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 25 Mar 2019 19:01:55 +0000 Subject: [PATCH] Test black compliance for all possible options --- requirements.txt | 1 + tests/test_cookiecutter_generation.py | 39 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/requirements.txt b/requirements.txt index 647bccaef..f5b71f6e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ binaryornot==0.4.4 # Code quality # ------------------------------------------------------------------------------ +black==19.3b0 flake8==3.7.6 # Testing diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 5cadb8d98..64512d3cd 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -119,6 +119,45 @@ def test_flake8_compliance( pytest.fail(e) +@pytest.mark.parametrize("windows", BINARY_CHOICES) +@pytest.mark.parametrize("use_docker", 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")], +) +def test_black_compliance( + cookies, + windows, + use_docker, + use_celery, + use_mailhog, + use_sentry, + use_compressor, + use_whitenoise, +): + """Generated project should pass black""" + result = cookies.bake( + extra_context={ + "windows": windows, + "use_docker": use_docker, + "use_compressor": use_compressor, + "use_celery": use_celery, + "use_mailhog": use_mailhog, + "use_sentry": use_sentry, + "use_whitenoise": use_whitenoise, + } + ) + + try: + sh.black("--check", "--diff", "--exclude", "migrations", f"{result.project}/") + except sh.ErrorReturnCode as e: + pytest.fail(e) + + def test_travis_invokes_pytest(cookies, context): context.update({"use_travisci": "y"}) result = cookies.bake(extra_context=context)