Merge ~cjwatson/lazr.restful:coverage into lazr.restful:main

Proposed by Colin Watson
Status: Merged
Merged at revision: 5b51fbd1cac70f7cd0acfc445fcf70ee6a95c50a
Proposed branch: ~cjwatson/lazr.restful:coverage
Merge into: lazr.restful:main
Diff against target: 52 lines (+19/-0)
2 files modified
.gitignore (+2/-0)
tox.ini (+17/-0)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+414029@code.launchpad.net

Commit message

Add coverage testing

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote (last edit ):

Thanks a lot! Not sure what bit I was missing.

Coverage is and remains magic :-)

The current output looks like...

```
.tox/coverage/lib/python3.8/site-packages/lazr/restful/tests/test_etag.py 118 9 92% 47, 52-56, 64-67, 74-89, 100-120
.tox/coverage/lib/python3.8/site-packages/lazr/restful/tests/test_navigation.py 69 1 99% 58
.tox/coverage/lib/python3.8/site-packages/lazr/restful/tests/test_utils.py 116 0 100%
.tox/coverage/lib/python3.8/site-packages/lazr/restful/tests/test_webservice.py 525 5 99% 119, 873, 1011, 1032, 1061
.tox/coverage/lib/python3.8/site-packages/lazr/restful/utils.py 193 6 97% 152, 306, 402, 451-459
.tox/coverage/lib/python3.8/site-packages/lazr/restful/wsgi.py 36 18 50% 32-33, 36-50, 57-61, 66-67
--------------------------------------------------------------------------------------------------------------------------------------
TOTAL 6636 434 93%
__________________________________________________________________________________ summary ___________________________________________________________________________________
  coverage: commands succeeded
  congratulations :)
```

Usually, you would add a `[coverage:paths]` section, and add something like...

```
[coverage:paths]
source =
    src
    .tox/*/site-packages
```

and then you'd get a nicer output (ie src/lazr/restful/.../test_function.py ...), but for reasons unknown it does not work here, at least for me.

review: Approve
Revision history for this message
Colin Watson (cjwatson) wrote :

Right, I tried `coverage:paths` too and couldn't see why it wasn't working. Odd, but I didn't want to spend too much time on it, and this at least works.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.gitignore b/.gitignore
2index ee6caa6..d2b3b94 100644
3--- a/.gitignore
4+++ b/.gitignore
5@@ -1,10 +1,12 @@
6 *.egg-info
7 *.pyc
8+.coverage
9 .DS_Store
10 .tox
11 bin
12 build
13 dist
14+htmlcov
15 MANIFEST
16 src/lazr/restful/docs/_build
17 TAGS
18diff --git a/tox.ini b/tox.ini
19index c191378..4b07cac 100644
20--- a/tox.ini
21+++ b/tox.ini
22@@ -8,6 +8,7 @@ envlist =
23 py39
24 py310
25 docs
26+ coverage
27
28 [testenv]
29 deps =
30@@ -31,6 +32,22 @@ deps =
31 commands =
32 sphinx-build -b html -d src/lazr/restful/docs/_build/doctrees src/lazr/restful/docs src/lazr/restful/docs/_build/html
33
34+[testenv:coverage]
35+basepython = python3
36+deps =
37+ .[test,xml]
38+ zope.testrunner
39+ coverage
40+commands =
41+ coverage erase
42+ coverage run -m zope.testrunner --test-path src --tests-pattern ^tests {posargs}
43+ coverage html
44+ coverage report -m --fail-under=93
45+
46+[coverage:run]
47+source = lazr.restful
48+omit = */docs/conf.py
49+
50 [flake8]
51 ignore =
52 # incompatible with black

Subscribers

People subscribed via source and target branches