Skip to content

Commit 79a3101

Browse files
authored
Merge pull request #642 from NLeSC/594-remove-tests-from-minimum
2 parents d4632bd + d55fbb4 commit 79a3101

7 files changed

Lines changed: 21 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Make SonarCloud optional [#515](https://github.com/NLeSC/python-template/pull/515)
1616
* Make citation optional [#471](https://github.com/NLeSC/python-template/pull/471)
1717
* Make online documentation optional [#476](https://github.com/NLeSC/python-template/pull/476)
18+
* Make local test optional [#594](https://github.com/NLeSC/python-template/pull/594)
1819

1920
### Changed
2021
* Update the user documentation (README.md) of the template [#575](https://github.com/NLeSC/python-template/pull/623)

copier/questions/features_code_quality.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ SelectCodeQualityFeatures:
77
type: yaml
88
default: |-
99
{% if template_profile == 'recommended' %}
10-
[SelectGitHubActions_flag, AddLinting_flag, AddSonarCloud_flag, AddEditorConfig_flag]
10+
[AddLocalTests_flag, SelectGitHubActions_flag, AddLinting_flag, AddSonarCloud_flag, AddEditorConfig_flag]
1111
{%- else -%}
1212
[]
1313
{%- endif %}
1414
help: Select code quality features
1515
multiselect: true
1616
choices:
17+
Local tests:
18+
value: AddLocalTests_flag
19+
# validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}"
1720
GitHub Actions (selection on the next menu):
1821
value: SelectGitHubActions_flag
1922
# validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}"
@@ -56,6 +59,10 @@ SelectGitHubActions:
5659

5760

5861
# computed features
62+
AddLocalTests:
63+
type: bool
64+
default: "{{ 'AddLocalTests_flag' in SelectCodeQualityFeatures or 'AddGitHubActionBuild_flag' in SelectGitHubActions or 'AddSonarCloud_flag' in SelectCodeQualityFeatures }}"
65+
when: false
5966
AddGitHubActionBuild:
6067
type: bool
6168
default: "{{ 'AddGitHubActionBuild_flag' in SelectGitHubActions }}"

template/project_setup.md.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ You can distribute your code using PyPI.
3535
[The guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=building-and-packaging-code) can
3636
help you decide which tool to use for packaging.
3737

38+
{% if AddLocalTests -%}
3839
## Testing and code coverage
3940

4041
- Tests should be put in the `tests` folder.
@@ -47,6 +48,7 @@ help you decide which tool to use for packaging.
4748
- The project uses [GitHub action workflows](https://docs.github.com/en/actions) to automatically run tests on GitHub infrastructure against multiple Python versions
4849
- Workflows can be found in [`.github/workflows`](.github/workflows/)
4950
- [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=testing)
51+
{%- endif %}
5052

5153
## Documentation
5254

template/pyproject.toml.jinja

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ version = "{{ version }}"
4545
dev = [
4646
"build", # build is not only used in publishing (below), but also in the template's test suite
4747
"bump-my-version",
48+
{%- if AddLocalTests %}
4849
"coverage [toml]",
4950
"pytest",
5051
"pytest-cov",
52+
{%- endif %}
5153
"ruff",
5254
"sphinx",
5355
"sphinx_rtd_theme",
@@ -76,22 +78,28 @@ Changelog = "{{ repository_url }}/CHANGELOG.md"
7678
{% if AddOnlineDocumentation -%}
7779
ReadTheDocs = "https://{{ package_name }}.readthedocs.io"
7880
{% endif %}
81+
{% if AddLocalTests -%}
7982
[tool.pytest.ini_options]
8083
testpaths = ["tests"]
84+
{% endif %}
8185

86+
{% if AddLocalTests -%}
8287
[tool.coverage.run]
8388
branch = true
8489
source = ["src/{{ package_name }}"]
8590
command_line = "-m pytest"
91+
{%- endif %}
8692

8793
[tool.tox]
8894
legacy_tox_ini = """
8995
[tox]
9096
envlist = py38,py39,py310,py311,py312
9197
skip_missing_interpreters = true
98+
{% if AddLocalTests -%}
9299
[testenv]
93100
commands = pytest
94101
extras = dev
102+
{%- endif %}
95103
"""
96104

97105
[tool.ruff]

template/{% if AddContributing %}CONTRIBUTING.md{% endif %}.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ The sections below outline the steps in each case.
3434
{% if AddDevDoc -%}
3535
1. install dependencies (see the [development documentation](README.dev.md#development_install));
3636
{%- endif %}
37+
{% if AddLocalTests -%}
3738
1. make sure the existing tests still work by running ``pytest``;
3839
1. add your own tests (if necessary);
40+
{%- endif %}
3941
1. update or expand the documentation;
4042
{% if AddChangeLog -%}
4143
1. update the `CHANGELOG.md` file with your change;

template/tests/__init__.py renamed to template/{% if AddLocalTests %}tests{% endif %}/__init__.py

File renamed without changes.

template/tests/test_my_module.py.jinja renamed to template/{% if AddLocalTests %}tests{% endif %}/test_my_module.py.jinja

File renamed without changes.

0 commit comments

Comments
 (0)