diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 9b07ada11..b0f55a52a 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -111,6 +111,9 @@ You need to install ``tox`` (``pip3 install tox``) to run tests and lint checks # run unit tests in one python environment only (useful for quick testing during development): tox -e py311 + # run a specific unit test file: + tox -e py311 -- tests/unit/objects/test_projects.py + # run unit and smoke tests in one python environment only tox -e py312,smoke @@ -148,9 +151,15 @@ To run these tests: # run the CLI tests: tox -e cli_func_v4 + # run a specific CLI functional test file: + tox -e cli_func_v4 -- tests/functional/cli/test_cli_v4.py + # run the python API tests: tox -e api_func_v4 + # run a specific API functional test file: + tox -e api_func_v4 -- tests/functional/api/test_projects.py + When developing tests it can be a little frustrating to wait for GitLab to spin up every run. To prevent the containers from being cleaned up afterwards, pass ``--keep-containers`` to pytest, i.e.: diff --git a/tox.ini b/tox.ini index 0ba295692..bfc11a969 100644 --- a/tox.ini +++ b/tox.ini @@ -26,6 +26,7 @@ passenv = NO_COLOR PWD PY_COLORS + USER setenv = DOCS_SOURCE = docs DOCS_BUILD = build/sphinx/html @@ -35,10 +36,13 @@ usedevelop = True install_command = pip install {opts} {packages} -e . isolated_build = True + +[testenv:py{314,313,312,311,310}] +description = Runs unit tests. For a specific test: tox -e py311 -- deps = -r{toxinidir}/requirements.txt -r{toxinidir}/requirements-test.txt commands = - pytest tests/unit {posargs} + pytest {posargs:tests/unit} [testenv:black] basepython = python3 @@ -115,6 +119,8 @@ deps = -r{toxinidir}/requirements-docs.txt commands = sphinx-autobuild {env:DOCS_SOURCE} {env:DOCS_BUILD} --open-browser --port 8000 [testenv:cover] +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/requirements-test.txt commands = pytest --cov --cov-report term --cov-report html \ --cov-report xml tests/unit {posargs} @@ -131,14 +137,20 @@ exclude_lines = return NotImplemented [testenv:cli_func_v4] -deps = -r{toxinidir}/requirements-docker.txt +description = + Runs CLI functional tests. For a specific test: tox -e cli_func_v4 -- +deps = -r{toxinidir}/requirements-test.txt + -r{toxinidir}/requirements-docker.txt commands = - pytest --script-launch-mode=subprocess --cov --cov-report xml tests/functional/cli {posargs} + pytest --script-launch-mode=subprocess --cov --cov-report xml {posargs:tests/functional/cli} [testenv:api_func_v4] -deps = -r{toxinidir}/requirements-docker.txt +description = + Runs API functional tests. For a specific test: tox -e api_func_v4 -- +deps = -r{toxinidir}/requirements-test.txt + -r{toxinidir}/requirements-docker.txt commands = - pytest --cov --cov-report xml tests/functional/api {posargs} + pytest --cov --cov-report xml {posargs:tests/functional/api} [testenv:smoke] deps = -r{toxinidir}/requirements-test.txt