Examine coverage in Python

memorandum put coverage

$ pip install coverage

Try

$ nosetests --with-coverage
..................
Name                        Stmts   Miss Branch BrMiss  Cover   Missing
-----------------------------------------------------------------------
ctypes                        333    333    108    108     0%   3-543
ctypes._endian                 33     33     14     14     0%   1-59
ctypes.macholib                 1      1      0      0     0%   9
ctypes.macholib.dyld           88     88     42     42     0%   5-158
ctypes.macholib.dylib          20     20      4      4     0%   5-63
ctypes.macholib.framework      23     23      4      4     0%   5-65
ctypes.util                   159    159     69     69     0%   1-236
mymodule                          6      0      0      0   100%
uuid                          301    301    131    131     0%   47-581
-----------------------------------------------------------------------
TOTAL                        1256    966    460    384    21%
----------------------------------------------------------------------
Ran 18 tests in 0.073s

OK

It was full! I want to erase the information of unnecessary modules!

$ nosetests --with-coverage --cover-package=mymodule                                                                                                    
..................
Name                    Stmts   Miss Branch BrMiss  Cover   Missing
-------------------------------------------------------------------
mymodule                      6      0      0      0   100%
-------------------------------------------------------------------
TOTAL                     298      8     88     12    100%
----------------------------------------------------------------------
Ran 18 tests in 0.073s

OK

Had disappeared!

By the way, the options are getting longer, so make it a configuration file

.noserc


[nosetests]
with-coverage=true
cover-package=mymodule

Run

$ nosetests --config=.noserc

The end

Recommended Posts

Examine coverage in Python
Examine the object's class in python
Quadtree in Python --2
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Unittest in python
Discord in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
Sorted list in Python
Daily AtCoder # 36 in Python
Clustering text in Python
Daily AtCoder # 2 in Python
Implement Enigma in python
Daily AtCoder # 32 in Python
Daily AtCoder # 6 in Python
Edit fonts in Python
Singleton pattern in Python
File operations in Python
Read DXF in python
Daily AtCoder # 53 in Python
Key input in Python
Use config.ini in Python
Daily AtCoder # 33 in Python
Solve ABC168D in Python
Logistic distribution in Python
Daily AtCoder # 7 in Python
One liner in Python