From e2cedecf4d214bca4e7e3fbb478ef09094b3079a Mon Sep 17 00:00:00 2001 From: Ashwin Krishna Date: Wed, 13 Mar 2024 00:42:32 +0000 Subject: [PATCH] change: split coverage out from testenv in tox.ini --- CONTRIBUTING.md | 4 ++-- tox.ini | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c1ea591249..24226af4ee 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,8 +77,8 @@ Before sending us a pull request, please ensure that: 1. Install coverage using `pip install .[test]` 1. cd into the sagemaker-python-sdk folder: `cd sagemaker-python-sdk` or `cd /environment/sagemaker-python-sdk` 1. Run the following tox command and verify that all code checks and unit tests pass: `tox tests/unit` - -You can also run a single test with the following command: `tox -e py310 -- -s -vv ::` +1. You can also run a single test with the following command: `tox -e py310 -- -s -vv ::` +1. You can run coverage via runcvoerage env : `tox -e runcoverage -- tests/unit` or `tox -e py310 -- tests/unit --cov=sagemaker --cov-append --cov-report xml` * Note that the coverage test will fail if you only run a single test, so make sure to surround the command with `export IGNORE_COVERAGE=-` and `unset IGNORE_COVERAGE` * Example: `export IGNORE_COVERAGE=- ; tox -e py310 -- -s -vv tests/unit/test_estimator.py::test_sagemaker_model_s3_uri_invalid ; unset IGNORE_COVERAGE` diff --git a/tox.ini b/tox.ini index d990467b3b..0c1c347c0d 100644 --- a/tox.ini +++ b/tox.ini @@ -86,12 +86,17 @@ commands = pip install 'torchvision==0.15.2+cpu' -f 'https://download.pytorch.org/whl/torch_stable.html' pip install 'dill>=0.3.8' - pytest --cov=sagemaker --cov-append {posargs} -{env:IGNORE_COVERAGE:} coverage report -i --fail-under=86 + pytest {posargs} deps = .[test] depends = {py38,py39,py310,p311}: clean +[testenv:runcoverage] +description = run unit tests with coverage +commands = + pytest --cov=sagemaker --cov-append {posargs} + {env:IGNORE_COVERAGE:} coverage report -i --fail-under=86 + [testenv:flake8] skipdist = true skip_install = true