Skip to content

Commit af42f43

Browse files
committed
run.sh: more readable coverage commands.
1 parent 3c13751 commit af42f43

File tree

3 files changed

+13
-28
lines changed

3 files changed

+13
-28
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ tests = [
9797
"pytest-subtests",
9898
"pytest-rerunfailures",
9999
"coverage",
100-
"pytest-cov",
101100
"requests-mock",
102101
# mechanicalsoup hard-depends on lxml (see below)
103102
'mechanicalsoup; (implementation_name != "pypy" and python_version <= "3.12")',

run.sh

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,21 @@ function install-dev {
3636
pre-commit install --install-hooks
3737
}
3838

39-
4039
function test {
4140
pytest --runslow "$@"
4241
}
4342

44-
45-
function coverage-all {
46-
clean-pyc
47-
# TODO: do we need to --cov-context=test all the time?
48-
coverage-run --cov-context=test "$@"
49-
coverage-report --show-contexts
50-
}
51-
52-
function coverage-run {
53-
# TODO: is pytest-cov needed?
54-
pytest --runslow --cov "$@"
43+
function coverage {
44+
unset -f coverage
45+
coverage run -m pytest --runslow "$@"
46+
coverage html
47+
coverage-report
5548
}
5649

5750
function coverage-report {
58-
coverage html "$@"
51+
# library only "coverage report --fail-under 100"
52+
unset -f coverage
5953
coverage report \
60-
--include '*/reader/*' \
6154
--omit "$(
6255
echo "
6356
*/reader/_vendor/*
@@ -76,7 +69,7 @@ function coverage-report {
7669

7770

7871
function test-all {
79-
tox -p
72+
tox p "$@"
8073
}
8174

8275

@@ -147,21 +140,12 @@ function entr-project-files {
147140
}
148141

149142

150-
function clean-pyc {
151-
local IFS=$'\n'
152-
find \
153-
$( ls-project-files | grep / | cut -d/ -f1 | uniq ) \
154-
-name '*.pyc' -or -name '*.pyo' \
155-
-exec rm -rf {} +
156-
}
157-
158-
159143
function ci-install {
160144
pip install -e '.[all]' --group tests --group typing
161145
}
162146

163147
function ci-run {
164-
coverage-run -v && coverage-report && typing
148+
command coverage run -m pytest --runslow && coverage-report && typing
165149
}
166150

167151

tox.ini

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependency_groups = tests
88
allowlist_externals =
99
./run.sh
1010

11-
commands = {posargs:./run.sh coverage-run --cov-append -v}
11+
commands = coverage run --append -m pytest --runslow
1212

1313
depends =
1414
py{313,312,311,py311}: coverage-clean
@@ -22,7 +22,9 @@ commands = coverage erase
2222
[testenv:coverage-report]
2323
deps = coverage
2424
skip_install = true
25-
commands = ./run.sh coverage-report
25+
commands =
26+
coverage html
27+
./run.sh coverage-report
2628

2729
[testenv:typing]
2830
dependency_groups = typing

0 commit comments

Comments
 (0)