Skip to content

Commit 0e596e3

Browse files
committed
simplify test setup and remove tox from template
1 parent 8f6dc27 commit 0e596e3

File tree

9 files changed

+22
-55
lines changed

9 files changed

+22
-55
lines changed

.github/workflows/cicd.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,4 @@ jobs:
2929
curl -sSL https://install.python-poetry.org | python3 -
3030
export PATH=$PATH:$HOME/.local/bin
3131
- name: Run tests
32-
env:
33-
TOX_ENV: ${{ matrix.python-version }}
3432
run: ./tests/test.sh

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ notebooks/
5454
.idea
5555

5656
# project artefacts
57-
test_project
57+
test_project*
5858
.python-version

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22

33
test:
44
./tests/test.sh
5+
6+
test-all:
7+
tox p

tests/test.sh

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
set -xe
1010

1111
CURRENT_DIR=$(pwd)
12+
PROJECT_DIR="test_project${TOX_ENV_NAME}"
1213

13-
rm -rf test_project
14+
rm -rf $PROJECT_DIR
1415

1516
cookiecutter --no-input --default-config \
16-
-o test_project \
17+
-o $PROJECT_DIR \
1718
. \
1819
author_name="Joe Doe" \
1920
author_email="joe@example.com" \
@@ -24,7 +25,7 @@ cookiecutter --no-input --default-config \
2425
license="MIT"
2526
echo "✅ Cookiecutter executes successfully."
2627

27-
cd test_project/my_project
28+
cd $PROJECT_DIR/my_project
2829

2930
poetry install
3031

@@ -41,16 +42,10 @@ make docs
4142
echo "✅ Documentation builds."
4243

4344
# check that the tests pass (apart from the test_reminder which always fails)
44-
TOX_ARGS="-k 'not test_reminder'" make test
45-
46-
# check that the test_reminder fails
47-
if TOX_ARGS="-k test_reminder" make test ; then
48-
echo 'test_reminder test does not fail.' >&2
49-
exit 1
50-
fi
51-
echo "✅ test_reminder test failed as expected."
45+
make test
46+
echo "✅ The tests pass."
5247

5348
cd "${CURRENT_DIR}"
54-
#rm -rf test_project
49+
rm -rf $PROJECT_DIR
5550

5651
echo "✅ Cookiecutter project tested successfully. All good 🤩"

tox.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
requires = ["tox>=4"]
2+
env_list = ["3.13", "3.12", "3.11", "3.10", "pypy3.10"]
3+
4+
[env_run_base]
5+
description = "Test that the cookiecutter builds."
6+
deps = [
7+
"cookiecutter"
8+
]
9+
allowlist_externals = ["make"]
10+
commands = [["make", { replace = "posargs", default = ["test"], extend = true }]]

{{ cookiecutter.project_slug }}/.github/workflows/cicd.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ jobs:
6161
with:
6262
fail_ci_if_error: true
6363
# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
64-
- name: Install tox, tox-gh
65-
run: python -m pip install tox tox-gh
66-
- name: Setup test suite
67-
run: python -mtox r --notest
6864
- name: Run test suite
6965
run: python -mtox r --skip-pkg-install
7066
env:
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
SHELL := /bin/bash
22

33
.PHONY: docs
4-
TOX_ARGS?=
54

65
install:
76
poetry install
@@ -13,16 +12,11 @@ clean_docs:
1312
cd docs && make clean
1413

1514
test: install
16-
poetry run tox -r run-parallel -- -- $(TOX_ARGS)
15+
poetry run pytest tests
1716

1817
docs:
1918
cd docs && poetry run make html
2019
echo You can now browse the documentation at ./docs/build/index.html
2120

2221
build: docs
2322
poetry build
24-
25-
# deactivated by default to prevent accidental uploads
26-
publish: test clean build
27-
echo "NOT uploading to PyPI. You need to uncomment the command in the Makefile."
28-
# poetry run python -mtwine upload dist/* --verbose

{{ cookiecutter.project_slug }}/tests/test_{{ cookiecutter.project_slug }}.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22

33
import {{ cookiecutter.project_slug }}
44

5-
# TODO: implement your tests here!
6-
7-
8-
def test_reminder():
9-
"""Reminder to write tests."""
10-
assert False, (
11-
"If this test runs it probably means that you have not written your own tests yet 😱 Do it now!"
12-
)
13-
145

156
def test_version_is_semver_string():
167
"""Test that the version in pyproject.toml is a proper semantic version."""

{{ cookiecutter.project_slug }}/tox.ini

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)