Skip to content

Commit

Permalink
Add jinja template to pytest coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
synacktraa committed Oct 4, 2024
1 parent e23ddfb commit 6aab0d6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cookiecutter-poetry"
version = "0.1.0"
description = "A python cookiecutter application to create a new python project that uses poetry to manage its dependencies."
authors = ["Florian Maas <[email protected]>", "Harsh Verma <[email protected]>"]
authors = ["Florian Maas <[email protected]>"]
repository = "https://github.com/fpgmaas/cookiecutter-poetry"
documentation = "https://fpgmaas.github.io/cookiecutter-poetry/"
readme = "README.md"
Expand Down
10 changes: 8 additions & 2 deletions tests/test_cookiecutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ def test_codecov(cookies, tmp_path):
with run_within_dir(tmp_path):
result = cookies.bake()
assert result.exit_code == 0
assert is_valid_yaml(result.project_path / ".github" / "workflows" / "main.yml")

main_yml_file = f"{result.project_path}/.github/workflows/main.yml"
assert is_valid_yaml(main_yml_file)
assert file_contains_text(main_yml_file, "--cov --cov-config=pyproject.toml --cov-report=xml")
assert os.path.isfile(f"{result.project_path}/codecov.yaml")
assert os.path.isfile(f"{result.project_path}/.github/workflows/validate-codecov-config.yml")

Expand All @@ -144,7 +147,10 @@ def test_not_codecov(cookies, tmp_path):
with run_within_dir(tmp_path):
result = cookies.bake(extra_context={"codecov": "n"})
assert result.exit_code == 0
assert is_valid_yaml(result.project_path / ".github" / "workflows" / "main.yml")

main_yml_file = f"{result.project_path}/.github/workflows/main.yml"
assert is_valid_yaml(main_yml_file)
assert not file_contains_text(main_yml_file, "--cov --cov-config=pyproject.toml --cov-report=xml")
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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ jobs:
python-version: {% raw %}${{ matrix.python-version }}{% endraw %}

- name: Run tests
{%- if cookiecutter.codecov == "y"%}
run: poetry run pytest tests --cov --cov-config=pyproject.toml --cov-report=xml
{%- else %}
run: poetry run pytest tests
{%- endif %}

- name: Check typing
run: poetry run {{ cookiecutter.typechecking }}

{% if cookiecutter.codecov == "y" %}
- name: Upload coverage reports to Codecov with GitHub Action on Python 3.11
uses: codecov/codecov-action@v4
Expand Down
6 changes: 5 additions & 1 deletion {{cookiecutter.project_name}}/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ passenv = PYTHON_VERSION
allowlist_externals = poetry
commands =
poetry install -v
pytest --doctest-modules tests --cov --cov-config=pyproject.toml --cov-report=xml
{%- if cookiecutter.codecov == "y"%}
pytest --doctest-modules tests --cov --cov-config=pyproject.toml --cov-report=xml
{%- else %}
pytest --doctest-modules tests
{%- endif %}
{{cookiecutter.typechecking}}

0 comments on commit 6aab0d6

Please sign in to comment.