Skip to content

Instantly share code, notes, and snippets.

@bilderbuchi
Last active December 23, 2015 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bilderbuchi/6697184 to your computer and use it in GitHub Desktop.
Save bilderbuchi/6697184 to your computer and use it in GitHub Desktop.
Coverage bug demonstration. Existing source argument does not make include argument ignored
< this uses https://github.com/bilderbuchi/ofStateManager/tree/5a61f2159fe6d4da6b3a60521e9e62c82b634cae
clone the repo and try it out>
ofStateManager$ cd tests/
ofStateManager/tests$ ./run_coverage.py
============================= test session starts ==============================
platform linux2 -- Python 2.7.4 -- pytest-2.3.5
plugins: cov
collected 34 items
test_archive.py .....
test_checkout.py ......
test_help.py .....
test_list.py ....
test_record.py ............
test_validate_git_repo.py ..
========================== 34 passed in 12.03 seconds ==========================
Name Stmts Miss Branch BrMiss Cover
-------------------------------------------------------------------------------------------------------
/home/cbuchner/Dropbox/Visuals/Coding/ofStateManager/ofStateManager 326 8 102 8 96%
<this is as intended. now, edit run_coverage.py, strip out the include=... kwarg in coverage.coverage(..)
L20 becomes cov = coverage.coverage(source=os.path.join(testdir, '..'))>
ofStateManager/tests$ ./run_coverage.py
============================= test session starts ==============================
platform linux2 -- Python 2.7.4 -- pytest-2.3.5
plugins: cov
collected 34 items
test_archive.py .....
test_checkout.py ......
test_help.py .....
test_list.py ....
test_record.py ............
test_validate_git_repo.py ..
========================== 34 passed in 11.22 seconds ==========================
Name Stmts Miss Branch BrMiss Cover
--------------------------------------------------------------------------------------------------------------------
/etc/python2.7/sitecustomize 5 2 0 0 60%
/home/cbuchner/.local/bin/coverage 5 0 2 1 86%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/__init__ 1 0 0 0 100%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/assertion/__init__ 78 17 29 20 65%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/assertion/newinterpret 244 171 48 41 27%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/assertion/oldinterpret 402 327 80 75 17%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/assertion/reinterpret 36 14 12 6 58%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/assertion/rewrite 436 300 136 111 28%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/assertion/util 172 146 110 105 11%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/capture 163 32 58 24 75%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/config 355 95 126 67 66%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/core 387 104 141 68 67%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/doctest 75 53 23 19 27%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/genscript 51 38 14 13 22%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/helpconfig 138 79 58 33 43%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/hookspec 57 0 86 43 70%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/junitxml 142 92 34 32 30%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/main 463 134 141 76 65%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/mark 131 66 51 37 43%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/monkeypatch 71 40 32 23 39%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/nose 37 12 28 16 57%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/pastebin 56 38 14 11 30%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/pdb 73 44 18 17 33%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/python 1163 465 439 258 55%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/recwarn 65 52 8 8 18%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/resultlog 80 62 34 32 18%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/runner 289 111 88 51 57%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/skipping 197 134 104 92 25%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/terminal 382 180 203 136 46%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/tmpdir 42 6 6 4 79%
/home/cbuchner/.local/lib/python2.7/site-packages/_pytest/unittest 147 115 50 47 18%
/home/cbuchner/.local/lib/python2.7/site-packages/py/__init__ 5 0 0 0 100%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_apipkg 131 34 52 22 69%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_builtin 188 139 58 53 22%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_code/__init__ 0 0 0 0 100%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_code/code 518 372 165 160 22%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_code/source 294 151 111 74 44%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_error 50 33 6 5 32%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_io/__init__ 0 0 0 0 100%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_io/capture 264 99 102 62 56%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_io/saferepr 35 16 2 1 54%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_io/terminalwriter 215 140 82 58 33%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_path/__init__ 0 0 0 0 100%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_path/common 233 90 98 55 56%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_path/local 588 312 245 153 44%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_std 11 5 0 0 55%
/home/cbuchner/.local/lib/python2.7/site-packages/py/_xmlgen 168 114 42 40 27%
/home/cbuchner/.local/lib/python2.7/site-packages/py/test 6 2 2 1 63%
/home/cbuchner/.local/lib/python2.7/site-packages/pytest 8 2 2 1 70%
/home/cbuchner/.local/lib/python2.7/site-packages/pytest_cov 44 27 14 13 31%
/home/cbuchner/Dropbox/Visuals/Coding/ofStateManager/ofStateManager 326 8 102 8 96%
/usr/share/pyshared/apport/__init__ 40 26 14 14 26%
/usr/share/pyshared/apport/fileutils 193 158 80 75 15%
/usr/share/pyshared/apport/packaging 50 28 4 4 41%
/usr/share/pyshared/apport/packaging_impl 524 470 243 239 8%
/usr/share/pyshared/apport/report 846 788 488 487 4%
/usr/share/pyshared/apport_python_hook 108 79 46 40 23%
/usr/share/pyshared/apt/__init__ 10 0 2 1 92%
/usr/share/pyshared/apt/cache 432 334 132 127 18%
/usr/share/pyshared/apt/cdrom 34 22 16 15 26%
/usr/share/pyshared/apt/deprecation 43 18 12 11 47%
/usr/share/pyshared/apt/package 662 479 159 154 23%
/usr/share/pyshared/apt/progress/__init__ 5 0 2 1 86%
/usr/share/pyshared/apt/progress/base 126 83 66 48 32%
/usr/share/pyshared/apt/progress/old 109 55 28 20 45%
/usr/share/pyshared/apt/progress/text 150 122 46 46 14%
/usr/share/pyshared/mpl_toolkits/__init__ 4 2 0 0 50%
/usr/share/pyshared/pkg_resources 1384 633 549 324 50%
/usr/share/pyshared/problem_report 370 337 210 203 7%
/usr/share/pyshared/zope/__init__ 6 3 0 0 50%
conftest 17 0 0 0 100%
test_archive 48 0 2 0 100%
test_checkout 58 0 6 0 100%
test_help 28 0 0 0 100%
test_list 49 0 2 0 100%
test_record 89 0 2 0 100%
test_validate_git_repo 16 0 2 0 100%
util_functions 18 0 4 1 95%
--------------------------------------------------------------------------------------------------------------------
TOTAL 14446 8110 5371 3982 39%
<this clearly shows the include argument is relevant even if source argument is specified. It's also necessary to filter out all the unwanted chaff results (which _could_ be another bug, or just a consequence of the subprocess coverage process)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment