Skip to content
Merged
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ The sections below outline the steps in each case.
1. (**important**) announce your plan to the rest of the community _before you start working_. This announcement should be in the form of a (new) issue;
1. (**important**) wait until some kind of consensus is reached about your idea being a good idea;
1. if needed, fork the repository to your own Github profile and create your own feature branch off of the latest main commit. While working on your feature branch, make sure to stay up to date with the main branch by pulling in changes, possibly from the 'upstream' repository (follow the instructions [here](https://help.github.com/articles/configuring-a-remote-for-a-fork/) and [here](https://help.github.com/articles/syncing-a-fork/));
1. make sure the existing tests still work by running ``python setup.py test``;
1. Install dependencies with `pip3 install -r requirements.txt`;
1. make sure the existing tests still work by running ``pytest``. If project tests fails use ``pytest --keep-baked-projects`` to keep generated project in /tmp/pytest-* and investigate;
1. add your own tests (if necessary);
1. update or expand the documentation;
1. [push](http://rogerdudler.github.io/git-guide/) your feature branch to (your fork of) the Python Template repository on GitHub;
Expand Down
28 changes: 27 additions & 1 deletion tests/test_project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import pytest
import os
Comment thread
jspaaks marked this conversation as resolved.
import subprocess
import shlex


def test_project_folder(cookies):
Expand All @@ -8,3 +10,27 @@ def test_project_folder(cookies):
assert project.exception is None
assert project.project.basename == 'my-python-project'
assert project.project.isdir()


def run(command: str, dirpath: os.PathLike) -> subprocess.CompletedProcess:
return subprocess.run(shlex.split(command),
Comment thread
jspaaks marked this conversation as resolved.
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=dirpath,
text=True)


def test_pytest(cookies):
result = cookies.bake()
env_output = run('python3 -m venv env', result.project)
assert env_output.returncode == 0
latest_pip_output = run('env/bin/pip3 install --upgrade pip setuptools', result.project)
Comment thread
jspaaks marked this conversation as resolved.
assert latest_pip_output.returncode == 0
pip_output = run('env/bin/pip3 install --editable .[dev]', result.project)
Comment thread
jspaaks marked this conversation as resolved.
assert pip_output.returncode == 0

pytest_output = run('env/bin/pytest', result.project)
assert pytest_output.returncode == 0
assert '== 3 passed in' in pytest_output.stdout
assert (result.project / 'coverage.xml').exists()
assert (result.project / 'htmlcov/index.html').exists()
4 changes: 1 addition & 3 deletions {{cookiecutter.project_name}}/.github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,4 @@ jobs:
run: prospector -0 -o grouped -o pylint:pylint-report.txt
- name: Test
shell: bash -l {0}
run: |
pytest tests
pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml
run: pytest
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ You want to make some kind of change to the code base
#. (**important**) announce your plan to the rest of the community *before you start working*. This announcement should be in the form of a (new) issue;
#. (**important**) wait until some kind of consensus is reached about your idea being a good idea;
#. if needed, fork the repository to your own Github profile and create your own feature branch off of the latest main commit. While working on your feature branch, make sure to stay up to date with the main branch by pulling in changes, possibly from the 'upstream' repository (follow the instructions `here <https://help.github.com/articles/configuring-a-remote-for-a-fork/>`__ and `here <https://help.github.com/articles/syncing-a-fork/>`__);
#. make sure the existing tests still work by running ``python setup.py test``;
#. make sure the existing tests still work by running ``pytest``;
#. add your own tests (if necessary);
#. update or expand the documentation;
#. `push <http://rogerdudler.github.io/git-guide/>`_ your feature branch to (your fork of) the {{ cookiecutter.project_name }} repository on GitHub;
Expand Down
10 changes: 1 addition & 9 deletions {{cookiecutter.project_name}}/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,14 @@ The project setup is documented in `a separate document <project_setup.rst>`_. F
Installation
------------

To install {{ cookiecutter.package_name }}, do:
To install {{ cookiecutter.package_name }} from GitHub repository, do:

.. code-block:: console

git clone {{ cookiecutter.repository }}.git
cd {{ cookiecutter.project_name }}
python3 -m pip install .


Run tests (including coverage) with:

.. code-block:: console

python3 setup.py test


Documentation
*************

Expand Down
13 changes: 6 additions & 7 deletions {{cookiecutter.project_name}}/project_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ help you decide which tool to use for packaging.
- Tests should be put in the `tests` folder.
- The `tests` folder contains:
- Example tests that you should replace with your own meaningful tests (file: `test_my_module.py`)
- A test that checks whether your code conforms to the Python style guide (PEP 8) (file: `test_lint.py`)
- The testing framework used is [PyTest](https://pytest.org)
- [PyTest introduction](http://pythontesting.net/framework/pytest/pytest-introduction/)
- Tests can be run with `python setup.py test`
- This is configured in `setup.py` and `setup.cfg`
- Use [Travis CI](https://travis-ci.com/) to automatically run tests and to test using multiple Python versions
- Configuration can be found in `.travis.yml`
- [Getting started with Travis CI](https://docs.travis-ci.com/user/getting-started/)
- PyTest can be installed with `pip3 install --editable .[dev]`
- Tests can be run with `pytest`
- This is configured in `setup.cfg`
- Use [GitHub action workflow](https://docs.github.com/en/actions) to automatically run tests on GitHub infrastructure against multiple Python versions
- Workflow can be found in [`.github/workflows/build.yml`](.github/workflows/build.yml)
- [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=testing)

## Documentation
Expand All @@ -87,7 +86,7 @@ help you decide which tool to use for packaging.
## Coding style conventions and code quality

- Check your code style with `prospector`
- You may need run `pip install .[dev]` first, to install the required dependencies
- You may need run `pip install --editable .[dev]` first, to install the required dependencies
- You can use `yapf` to fix the readability of your code style and `isort` to format and group your imports
- [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=coding-style-conventions)

Expand Down
5 changes: 0 additions & 5 deletions {{cookiecutter.project_name}}/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
# - https://www.python.org/dev/peps/pep-0314/


[aliases]
# Define `python setup.py test`
test=pytest


[metadata]
author = {{ cookiecutter.full_name }}
author_email = {{ cookiecutter.email }}
Expand Down