From d27d700afeeacce06bd0b3021e9caa2fd628d89a Mon Sep 17 00:00:00 2001 From: Jon Zeolla Date: Wed, 16 Jul 2025 13:15:14 -0400 Subject: [PATCH 1/4] chore(tests): add a slow marker --- tests/test_cookiecutter.py | 1 + .../tests/test_integration.py" | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/test_cookiecutter.py b/tests/test_cookiecutter.py index f786177..59c53aa 100755 --- a/tests/test_cookiecutter.py +++ b/tests/test_cookiecutter.py @@ -212,6 +212,7 @@ def test_autofix_hook(cookies, context): @pytest.mark.integration +@pytest.mark.slow def test_default_project(cookies): """ Test a default project thoroughly diff --git "a/{{cookiecutter.project_name|replace(\" \", \"\")}}/tests/test_integration.py" "b/{{cookiecutter.project_name|replace(\" \", \"\")}}/tests/test_integration.py" index c0e6153..39920c2 100755 --- "a/{{cookiecutter.project_name|replace(\" \", \"\")}}/tests/test_integration.py" +++ "b/{{cookiecutter.project_name|replace(\" \", \"\")}}/tests/test_integration.py" @@ -13,6 +13,7 @@ @pytest.mark.integration +@pytest.mark.slow def test_project_tasks(): """ Test the project's task runner commands work together properly. From d76aa06d4552694a2785c8f96460fc7ea839728d Mon Sep 17 00:00:00 2001 From: Jon Zeolla Date: Wed, 16 Jul 2025 13:15:14 -0400 Subject: [PATCH 2/4] chore(tests): add a slow marker --- Taskfile.yml | 10 ++++++++-- .../Taskfile.yml" | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index b5c5c1b..132d026 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -76,13 +76,19 @@ tasks: unit-test: desc: Run the unit tests + vars: + # If CLI_ARGS are set, append them as an "and" after the -m unit + MARK_EXPR: unit{{if .CLI_ARGS}} and {{.CLI_ARGS}}{{end}} cmds: - - '{{.RUN_SCRIPT}} pytest --keep-baked-projects -m unit tests/' + - '{{.RUN_SCRIPT}} pytest --keep-baked-projects -m "{{.MARK_EXPR}}" tests/' integration-test: desc: Run the integration tests + vars: + # If CLI_ARGS are set, append them as an "and" after the -m integration + MARK_EXPR: integration{{if .CLI_ARGS}} and {{.CLI_ARGS}}{{end}} cmds: - - '{{.RUN_SCRIPT}} pytest --keep-baked-projects -m integration tests/' + - '{{.RUN_SCRIPT}} pytest --keep-baked-projects -m "{{.MARK_EXPR}}" tests/' update: desc: Update the project dev and runtime dependencies diff --git "a/{{cookiecutter.project_name|replace(\" \", \"\")}}/Taskfile.yml" "b/{{cookiecutter.project_name|replace(\" \", \"\")}}/Taskfile.yml" index 3cb6af8..bbafbea 100644 --- "a/{{cookiecutter.project_name|replace(\" \", \"\")}}/Taskfile.yml" +++ "b/{{cookiecutter.project_name|replace(\" \", \"\")}}/Taskfile.yml" @@ -164,17 +164,23 @@ tasks: unit-test: desc: Run the project unit tests deps: ["coverage-erase"] + vars: + # If CLI_ARGS are set, append them as an "and" after the -m unit + MARK_EXPR: unit{{ '{{if .CLI_ARGS}}' }} and {{ '{{.CLI_ARGS}}{{end}}' }} cmds: - - '{{ '{{.RUN_SCRIPT}}' }} pytest -m unit tests/' + - '{{ '{{.RUN_SCRIPT}}' }} pytest -m "{{ '{{.MARK_EXPR}}' }}" tests/' integration-test: desc: Run the project integration tests deps: ["coverage-erase"] + vars: + # If CLI_ARGS are set, append them as an "and" after the -m integration + MARK_EXPR: integration{{ '{{if .CLI_ARGS}}' }} and {{ '{{.CLI_ARGS}}{{end}}' }} status: # Only run integration tests when the PLATFORM is set to all or the same platform as we're running on - '{{ '{{if or (eq .PLATFORM "all") (eq .PLATFORM .LOCAL_PLATFORM) (not .PLATFORM)}}' }}exit 1{{ '{{else}}' }}exit 0{{ '{{end}}' }}' cmds: - - '{{ '{{.RUN_SCRIPT}}' }} pytest -m integration tests/' + - '{{ '{{.RUN_SCRIPT}}' }} pytest -m "{{ '{{.MARK_EXPR}}' }}" tests/' update: desc: Update the project dev and runtime dependencies From 8297aee5f8b7dad4584913f720b284efaeb241af Mon Sep 17 00:00:00 2001 From: Jon Zeolla Date: Wed, 16 Jul 2025 13:28:30 -0400 Subject: [PATCH 3/4] Update docs --- docs/testing.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/testing.md b/docs/testing.md index f6c496d..e76c5e5 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -20,6 +20,12 @@ task unit-test # Run unit tests only task integration-test # Run integration tests only ``` +If you'd like to exclude tests that are marked a certain way, you can pass additional details to the above tasks, for instance: + +```bash +task test -- "not slow" # Skip slow tests +``` + ### What Template Tests Cover - **Generation Validation**: Tests with various input combinations to ensure valid project generation From cf0a8d4afdedff6bd7898a520fd5c49f9b7b65c0 Mon Sep 17 00:00:00 2001 From: Jon Zeolla Date: Wed, 16 Jul 2025 13:37:54 -0400 Subject: [PATCH 4/4] Fix small bug --- .../.github/CODE_OF_CONDUCT.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "{{cookiecutter.project_name|replace(\" \", \"\")}}/.github/CONTRIBUTING.md" => "{{cookiecutter.project_name|replace(\" \", \"\")}}/.github/CODE_OF_CONDUCT.md" (100%) diff --git "a/{{cookiecutter.project_name|replace(\" \", \"\")}}/.github/CONTRIBUTING.md" "b/{{cookiecutter.project_name|replace(\" \", \"\")}}/.github/CODE_OF_CONDUCT.md" similarity index 100% rename from "{{cookiecutter.project_name|replace(\" \", \"\")}}/.github/CONTRIBUTING.md" rename to "{{cookiecutter.project_name|replace(\" \", \"\")}}/.github/CODE_OF_CONDUCT.md"