diff --git a/{{ cookiecutter.package_name }}/pyproject.toml b/{{ cookiecutter.package_name }}/pyproject.toml index 65f11d9..b62d903 100644 --- a/{{ cookiecutter.package_name }}/pyproject.toml +++ b/{{ cookiecutter.package_name }}/pyproject.toml @@ -33,9 +33,10 @@ open_astronomy_package_template_example = "{{ cookiecutter.module_name }}.exampl {% endif -%} [project.optional-dependencies] -test = [ +tests = [ "pytest", "pytest-doctestplus", + "pytest-cov", ] docs = [ "sphinx", diff --git a/{{ cookiecutter.package_name }}/tox.ini b/{{ cookiecutter.package_name }}/tox.ini index 549c04e..99a6387 100644 --- a/{{ cookiecutter.package_name }}/tox.ini +++ b/{{ cookiecutter.package_name }}/tox.ini @@ -1,57 +1,63 @@ [tox] min_version = 4.0 +requires = + tox-pypi-filter>=0.14 envlist = - py{38,39,310,311}-test - py38-test-oldestdeps + py{39,310,311,312} + py312-devdeps + py39-oldestdeps build_docs -isolated_build = true [testenv] -# tox environments are constructed with so-called 'factors' (or terms) -# separated by hyphens, e.g. test-devdeps-cov. Lines below starting with factor: -# will only take effect if that factor is included in the environment name. To -# see a list of example environments that can be run, along with a description, -# run: -# -# tox -l -v -# +pypi_filter = https://raw.githubusercontent.com/sunpy/sunpy/main/.test_package_pins.txt +# Run the tests in a temporary directory to make sure that we don't import +# the package from the source tree +change_dir = .tmp/{envname} description = run tests oldestdeps: with the oldest supported version of key dependencies + devdeps: with the latest developer version of key dependencies -# Pass through the following environment variables which may be needed for the CI -pass_env = - HOME - WINDIR - LC_ALL - LC_CTYPE - CC - CI - TRAVIS - -# Suppress display of matplotlib plots generated during docs build -set_env = +set_env = MPLBACKEND=agg - -# Run the tests in a temporary directory to make sure that we don't import -# the package from the source tree -change_dir = .tmp/{envname} + devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple + # Define the base test command here to allow us to add more flags for each tox factor + PYTEST_COMMAND = pytest -vvv -r fEs --pyargs {{ cookiecutter.module_name }} --cov-report=xml --cov={{ cookiecutter.module_name }} --cov-config={toxinidir}/pyproject.toml {toxinidir}/docs deps = + # For packages which publish nightly wheels this will pull the latest nightly + devdeps: numpy>=0.0.dev0 + # Packages without nightly wheels will be built from source like this + # devdeps: git+https://github.com/ndcube/ndcube oldestdeps: minimum_dependencies - pytest-cov -# The following indicates which extras_require from setup.cfg will be installed +# The following indicates which extras_require will be installed extras = - test + tests commands_pre = oldestdeps: minimum_dependencies packagename --filename requirements-min.txt oldestdeps: pip install -r requirements-min.txt - pip freeze + pip freeze --all --no-input commands = - pytest --pyargs packagename --cov {{ cookiecutter.module_name }} --cov-report xml:coverage.xml --cov-report term-missing {posargs} + # To run different commands for different factors exclude the factor from the default command like this + # !online: {env:PYTEST_COMMAND} {posargs} + # Then specify a specific one like this + # online: {env:PYTEST_COMMAND} --remote-data=any {posargs} + # If you have no factors which require different commands this is all you need: + {env:PYTEST_COMMAND} {posargs} + +# Uncomment this once we add pre-commit +#[testenv:codestyle] +#pypi_filter = +#skip_install = true +#description = Run all style and file checks with pre-commit +#deps = +# pre-commit +#commands = +# pre-commit install-hooks +# pre-commit run --color always --all-files --show-diff-on-failure [testenv:build_docs] description = invoke sphinx-build to build the HTML docs