diff --git a/tests/test_cookiecutter.py b/tests/test_cookiecutter.py index 2bb2e66..a8b9f8f 100644 --- a/tests/test_cookiecutter.py +++ b/tests/test_cookiecutter.py @@ -29,10 +29,7 @@ def test_using_pytest(cookies, tmp_path): # Install the poetry environment and run the tests. with run_within_dir(str(result.project_path)): - assert ( - subprocess.check_call(shlex.split("poetry install --no-interaction")) - == 0 - ) + assert subprocess.check_call(shlex.split("poetry install --no-interaction")) == 0 assert subprocess.check_call(shlex.split("poetry run make test")) == 0 @@ -42,9 +39,7 @@ def test_devcontainer(cookies, tmp_path): result = cookies.bake(extra_context={"devcontainer": "y"}) assert result.exit_code == 0 assert os.path.isfile(f"{result.project_path}/.devcontainer/devcontainer.json") - assert os.path.isfile( - f"{result.project_path}/.devcontainer/postCreateCommand.sh" - ) + assert os.path.isfile(f"{result.project_path}/.devcontainer/postCreateCommand.sh") def test_not_devcontainer(cookies, tmp_path): @@ -52,52 +47,34 @@ def test_not_devcontainer(cookies, tmp_path): with run_within_dir(tmp_path): result = cookies.bake(extra_context={"devcontainer": "n"}) assert result.exit_code == 0 - assert not os.path.isfile( - f"{result.project_path}/.devcontainer/devcontainer.json" - ) - assert not os.path.isfile( - f"{result.project_path}/.devcontainer/postCreateCommand.sh" - ) + assert not os.path.isfile(f"{result.project_path}/.devcontainer/devcontainer.json") + assert not os.path.isfile(f"{result.project_path}/.devcontainer/postCreateCommand.sh") def test_cicd_contains_artifactory_secrets(cookies, tmp_path): with run_within_dir(tmp_path): result = cookies.bake(extra_context={"publish_to": "artifactory"}) assert result.exit_code == 0 - assert is_valid_yaml( - result.project_path / ".github" / "workflows" / "on-release-main.yml" - ) + assert is_valid_yaml(result.project_path / ".github" / "workflows" / "on-release-main.yml") for text in ["ARTIFACTORY_URL", "ARTIFACTORY_USERNAME", "ARTIFACTORY_PASSWORD"]: - assert file_contains_text( - f"{result.project_path}/.github/workflows/on-release-main.yml", text - ) - assert file_contains_text( - f"{result.project_path}/Makefile", "build-and-publish" - ) + assert file_contains_text(f"{result.project_path}/.github/workflows/on-release-main.yml", text) + assert file_contains_text(f"{result.project_path}/Makefile", "build-and-publish") def test_cicd_contains_pypi_secrets(cookies, tmp_path): with run_within_dir(tmp_path): result = cookies.bake(extra_context={"publish_to": "pypi"}) assert result.exit_code == 0 - assert is_valid_yaml( - result.project_path / ".github" / "workflows" / "on-release-main.yml" - ) - assert file_contains_text( - f"{result.project_path}/.github/workflows/on-release-main.yml", "PYPI_TOKEN" - ) - assert file_contains_text( - f"{result.project_path}/Makefile", "build-and-publish" - ) + assert is_valid_yaml(result.project_path / ".github" / "workflows" / "on-release-main.yml") + assert file_contains_text(f"{result.project_path}/.github/workflows/on-release-main.yml", "PYPI_TOKEN") + assert file_contains_text(f"{result.project_path}/Makefile", "build-and-publish") def test_dont_publish(cookies, tmp_path): with run_within_dir(tmp_path): result = cookies.bake(extra_context={"publish_to": "none"}) assert result.exit_code == 0 - assert is_valid_yaml( - result.project_path / ".github" / "workflows" / "on-release-main.yml" - ) + assert is_valid_yaml(result.project_path / ".github" / "workflows" / "on-release-main.yml") assert not file_contains_text( f"{result.project_path}/.github/workflows/on-release-main.yml", "make build-and-publish", @@ -109,9 +86,7 @@ def test_mkdocs(cookies, tmp_path): result = cookies.bake(extra_context={"mkdocs": "y"}) assert result.exit_code == 0 assert is_valid_yaml(result.project_path / ".github" / "workflows" / "main.yml") - assert is_valid_yaml( - result.project_path / ".github" / "workflows" / "on-release-main.yml" - ) + assert is_valid_yaml(result.project_path / ".github" / "workflows" / "on-release-main.yml") assert file_contains_text( f"{result.project_path}/.github/workflows/on-release-main.yml", "mkdocs gh-deploy", @@ -125,9 +100,7 @@ def test_not_mkdocs(cookies, tmp_path): result = cookies.bake(extra_context={"mkdocs": "n"}) assert result.exit_code == 0 assert is_valid_yaml(result.project_path / ".github" / "workflows" / "main.yml") - assert is_valid_yaml( - result.project_path / ".github" / "workflows" / "on-release-main.yml" - ) + assert is_valid_yaml(result.project_path / ".github" / "workflows" / "on-release-main.yml") assert not file_contains_text( f"{result.project_path}/.github/workflows/on-release-main.yml", "mkdocs gh-deploy", @@ -164,9 +137,7 @@ def test_codecov(cookies, tmp_path): assert result.exit_code == 0 assert is_valid_yaml(result.project_path / ".github" / "workflows" / "main.yml") assert os.path.isfile(f"{result.project_path}/codecov.yaml") - assert os.path.isfile( - f"{result.project_path}/.github/workflows/validate-codecov-config.yml" - ) + assert os.path.isfile(f"{result.project_path}/.github/workflows/validate-codecov-config.yml") def test_not_codecov(cookies, tmp_path): @@ -175,24 +146,18 @@ def test_not_codecov(cookies, tmp_path): assert result.exit_code == 0 assert is_valid_yaml(result.project_path / ".github" / "workflows" / "main.yml") assert not os.path.isfile(f"{result.project_path}/codecov.yaml") - assert not os.path.isfile( - f"{result.project_path}/.github/workflows/validate-codecov-config.yml" - ) + assert not os.path.isfile(f"{result.project_path}/.github/workflows/validate-codecov-config.yml") def test_remove_release_workflow(cookies, tmp_path): with run_within_dir(tmp_path): result = cookies.bake(extra_context={"publish_to": "none", "mkdocs": "y"}) assert result.exit_code == 0 - assert os.path.isfile( - f"{result.project_path}/.github/workflows/on-release-main.yml" - ) + assert os.path.isfile(f"{result.project_path}/.github/workflows/on-release-main.yml") result = cookies.bake(extra_context={"publish_to": "none", "mkdocs": "n"}) assert result.exit_code == 0 - assert not os.path.isfile( - f"{result.project_path}/.github/workflows/on-release-main.yml" - ) + assert not os.path.isfile(f"{result.project_path}/.github/workflows/on-release-main.yml") def test_pyright(cookies, tmp_path): @@ -200,13 +165,9 @@ def test_pyright(cookies, tmp_path): result = cookies.bake(extra_context={"typechecking": "pyright"}) assert result.exit_code == 0 # check the toml file - assert file_contains_text( - f"{result.project_path}/pyproject.toml", "[tool.pyright]" - ) + assert file_contains_text(f"{result.project_path}/pyproject.toml", "[tool.pyright]") assert file_contains_text(f"{result.project_path}/pyproject.toml", "pyright =") - assert not file_contains_text( - f"{result.project_path}/pyproject.toml", "[tool.mypy]" - ) + assert not file_contains_text(f"{result.project_path}/pyproject.toml", "[tool.mypy]") assert not file_contains_text(f"{result.project_path}/pyproject.toml", "mypy =") # check the make file assert file_contains_text(f"{result.project_path}/Makefile", "pyright") @@ -221,16 +182,10 @@ def test_mypy(cookies, tmp_path): result = cookies.bake(extra_context={"typechecking": "mypy"}) assert result.exit_code == 0 # check the toml file - assert file_contains_text( - f"{result.project_path}/pyproject.toml", "[tool.mypy]" - ) + assert file_contains_text(f"{result.project_path}/pyproject.toml", "[tool.mypy]") assert file_contains_text(f"{result.project_path}/pyproject.toml", "mypy =") - assert not file_contains_text( - f"{result.project_path}/pyproject.toml", "[tool.pyright]" - ) - assert not file_contains_text( - f"{result.project_path}/pyproject.toml", "pyright =" - ) + assert not file_contains_text(f"{result.project_path}/pyproject.toml", "[tool.pyright]") + assert not file_contains_text(f"{result.project_path}/pyproject.toml", "pyright =") # check the make file assert file_contains_text(f"{result.project_path}/Makefile", "mypy") assert not file_contains_text(f"{result.project_path}/Makefile", "pyright")