Fix running tox with AUTOFIXABLE_STYLES

This commit is contained in:
Bruno Alla 2023-04-15 14:28:32 +01:00
parent 3db8f6acf3
commit b763318fdc
No known key found for this signature in database
2 changed files with 5 additions and 12 deletions

View File

@ -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 # 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 # 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. # 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 @pytest.fixture
@ -144,11 +144,7 @@ def _fixture_id(ctx):
def build_files_list(base_dir): def build_files_list(base_dir):
"""Build a list containing absolute paths to the generated files.""" """Build a list containing absolute paths to the generated files."""
return [ return [os.path.join(dirpath, file_path) for dirpath, subdirs, files in os.walk(base_dir) for file_path in files]
os.path.join(dirpath, file_path)
for dirpath, subdirs, files in os.walk(base_dir)
for file_path in files
]
def check_paths(paths): 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"), ("y", "docker-compose -f local.yml run django pytest"),
], ],
) )
def test_gitlab_invokes_precommit_and_pytest( def test_gitlab_invokes_precommit_and_pytest(cookies, context, use_docker, expected_test_script):
cookies, context, use_docker, expected_test_script
):
context.update({"ci_tool": "Gitlab", "use_docker": use_docker}) context.update({"ci_tool": "Gitlab", "use_docker": use_docker})
result = cookies.bake(extra_context=context) 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"), ("y", "docker-compose -f local.yml run django pytest"),
], ],
) )
def test_github_invokes_linter_and_pytest( def test_github_invokes_linter_and_pytest(cookies, context, use_docker, expected_test_script):
cookies, context, use_docker, expected_test_script
):
context.update({"ci_tool": "Github", "use_docker": use_docker}) context.update({"ci_tool": "Github", "use_docker": use_docker})
result = cookies.bake(extra_context=context) result = cookies.bake(extra_context=context)

View File

@ -4,6 +4,7 @@ envlist = py311,black-template
[testenv] [testenv]
deps = -rrequirements.txt deps = -rrequirements.txt
passenv = AUTOFIXABLE_STYLES
commands = pytest {posargs:./tests} commands = pytest {posargs:./tests}
[testenv:black-template] [testenv:black-template]