LoginSignup
7
7

More than 5 years have passed since last update.

Pythonでカバレッジを調べる

Posted at

備忘録
coverage入れる

$ pip install coverage

やってみる

$ 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

なんかいっぱいでた! 要らないモジュールの情報消したい!

$ 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

消えた!

ところでオプションが長くなってきたので設定ファイルにする

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

実行

$ nosetests --config=.noserc

おしまい

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7