Generate XML coverage report for Codecov
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f29d7da..adea761 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -59,7 +59,7 @@
- name: Run tests
run: |
source $VENV
- nox -e cov
+ nox -e cov -- xml
# Latest python version: send coverage report to codecov
- name: "Upload coverage report to Codecov"
diff --git a/noxfile.py b/noxfile.py
index 750bfb6..68348c5 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -25,8 +25,7 @@
UNIT_TESTS = join('tests', 'unit')
INTEGRATION_TESTS = join('tests', 'integration')
STRESS_TEST_MULTIPLIER = 10
-# Generate HTML + stdout coverage report
-COVERAGE_ARGS = '--cov --cov-report=term --cov-report=html'
+DEFAULT_COVERAGE_FORMATS = ['html', 'term']
# Run tests in parallel, grouped by test module
XDIST_ARGS = '--numprocesses=auto --dist=loadfile'
@@ -58,8 +57,11 @@
@session(python=False, name='cov')
def coverage(session):
"""Run tests and generate coverage report"""
- cmd = f'pytest {UNIT_TESTS} {INTEGRATION_TESTS} -rs {XDIST_ARGS} {COVERAGE_ARGS}'
- session.run(*cmd.split(' '))
+ cov_formats = session.posargs or DEFAULT_COVERAGE_FORMATS
+ cov_format_args = [f'--cov-report={f}' for f in cov_formats]
+
+ cmd = f'pytest {UNIT_TESTS} {INTEGRATION_TESTS} -rs {XDIST_ARGS} --cov'
+ session.run(*cmd.split(' '), *cov_format_args)
@session(python=False, name='stress')