From b763318fdc4f242ac88cfe904623b093a432cbd0 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sat, 15 Apr 2023 14:28:32 +0100 Subject: [PATCH] Fix running tox with AUTOFIXABLE_STYLES --- tests/test_cookiecutter_generation.py | 16 ++++------------ tox.ini | 1 + 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index e4a03b3b2..3dea23f94 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -23,7 +23,7 @@ elif sys.platform.startswith("darwin") and os.getenv("CI"): # Run auto-fixable styles checks - skipped on CI by default. These can be fixed # automatically by running pre-commit after generation however they are tedious # to fix in the template, so we don't insist too much in fixing them. -AUTOFIXABLE_STYLES = os.getenv("AUTOFIXABLE_STYLES") == 1 +AUTOFIXABLE_STYLES = os.getenv("AUTOFIXABLE_STYLES") == "1" @pytest.fixture @@ -144,11 +144,7 @@ def _fixture_id(ctx): def build_files_list(base_dir): """Build a list containing absolute paths to the generated files.""" - return [ - os.path.join(dirpath, file_path) - for dirpath, subdirs, files in os.walk(base_dir) - for file_path in files - ] + return [os.path.join(dirpath, file_path) for dirpath, subdirs, files in os.walk(base_dir) for file_path in files] def check_paths(paths): @@ -240,9 +236,7 @@ def test_travis_invokes_pytest(cookies, context, use_docker, expected_test_scrip ("y", "docker-compose -f local.yml run django pytest"), ], ) -def test_gitlab_invokes_precommit_and_pytest( - cookies, context, use_docker, expected_test_script -): +def test_gitlab_invokes_precommit_and_pytest(cookies, context, use_docker, expected_test_script): context.update({"ci_tool": "Gitlab", "use_docker": use_docker}) result = cookies.bake(extra_context=context) @@ -269,9 +263,7 @@ def test_gitlab_invokes_precommit_and_pytest( ("y", "docker-compose -f local.yml run django pytest"), ], ) -def test_github_invokes_linter_and_pytest( - cookies, context, use_docker, expected_test_script -): +def test_github_invokes_linter_and_pytest(cookies, context, use_docker, expected_test_script): context.update({"ci_tool": "Github", "use_docker": use_docker}) result = cookies.bake(extra_context=context) diff --git a/tox.ini b/tox.ini index f0c22d48e..b10d16427 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,7 @@ envlist = py311,black-template [testenv] deps = -rrequirements.txt +passenv = AUTOFIXABLE_STYLES commands = pytest {posargs:./tests} [testenv:black-template]