久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何使用nosetests從python覆蓋率報(bào)告中排除模擬包

How to exclude mock package from python coverage report using nosetests(如何使用nosetests從python覆蓋率報(bào)告中排除模擬包)
本文介紹了如何使用nosetests從python覆蓋率報(bào)告中排除模擬包的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我目前嘗試使用mock庫在python中編寫一些基本的鼻子單元測試.

I currently try to use the mock library to write some basic nose unittests in python.

完成一些基本示例后,我現(xiàn)在嘗試使用 nosetests --with-coverage,現(xiàn)在我有了模擬包,我嘗試模擬"的包顯示在覆蓋率報(bào)告中.有沒有可能排除這些?

After finishing some basic example I now tried to use nosetests --with-coverage and now I have the mock package and the package I tried to 'mock away' are shown in the coverage report. Is there a possibility to exclude these?

這是我要測試的課程:

from imaplib import IMAP4

class ImapProxy:
    def __init__(self, host):
        self._client = IMAP4(host)

還有測試用例:從模擬導(dǎo)入補(bǔ)丁

And the testcase: from mock import patch

from ImapProxy import ImapProxy

class TestImap:
    def test_connect(self):
        with patch('ImapProxy.IMAP4') as imapMock:
            proxy = ImapProxy("testhost")
            imapMock.assert_called_once_with("testhost")

我現(xiàn)在得到 nosetests --with-coverage

.
Name         Stmts   Miss  Cover   Missing
------------------------------------------
ImapProxy        4      0   100%   
imaplib        675    675     0%   23-1519
mock          1240    810    35%   [ a lot of lines]

有什么方法可以排除 mock 包和 imaplib 包而無需通過 --cover-package=PACKAGE

Is there any way to exclude the mock package and the imaplib package without having to manually whitelisting all but those packages by --cover-package=PACKAGE

感謝 Ned Batchelder,我現(xiàn)在知道了 .coveragerc 文件,謝謝!

Thanks to Ned Batchelder I now know about the .coveragerc file, thanks for that!

我創(chuàng)建了一個(gè)包含以下內(nèi)容的 .coveragerc 文件:

I created a .coveragerc file with the following content:

[report]
omit = *mock*

現(xiàn)在我在覆蓋率報(bào)告中的模擬輸出是:

Now my output for mock in the coverage report is:

mock                     1240   1240     0%   16-2356

它不再涵蓋模擬包,但仍顯示在報(bào)告中.

It does not cover the mock package any longer but still shows it in the report.

如果有幫助,我使用 Coverage.py,版本 3.5.2.

I use Coverage.py, version 3.5.2 if this is any help.

推薦答案

創(chuàng)建一個(gè) .coveragerc 文件,在報(bào)告中排除您不想要的內(nèi)容:http://nedbatchelder.com/code/coverage/config.html

Create a .coveragerc file that excludes what you don't want in the report: http://nedbatchelder.com/code/coverage/config.html

這篇關(guān)于如何使用nosetests從python覆蓋率報(bào)告中排除模擬包的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Python 3 Float Decimal Points/Precision(Python 3 浮點(diǎn)小數(shù)點(diǎn)/精度)
Converting Float to Dollars and Cents(將浮點(diǎn)數(shù)轉(zhuǎn)換為美元和美分)
What are some possible calculations with numpy or scipy that can return a NaN?(numpy 或 scipy 有哪些可能的計(jì)算可以返回 NaN?)
Python float to ratio(Python浮動(dòng)比率)
How to manage division of huge numbers in Python?(如何在 Python 中管理大量數(shù)字的除法?)
mean from pandas and numpy differ(pandas 和 numpy 的意思不同)
主站蜘蛛池模板: 久久99精品久久久久久国产越南 | 啪啪毛片 | 嫩草一区二区三区 | 午夜三级视频 | 男女羞羞在线观看 | 人人爽人人爽 | 中文在线a在线 | 国产又色又爽又黄又免费 | 日韩欧美专区 | 日韩二区| 日本精品视频 | 久久久婷 | 成人免费在线 | 91高清在线观看 | 91精品国产麻豆 | 欧美黑人一级爽快片淫片高清 | 国产午夜精品一区二区 | 久久久久久免费观看 | 欧美一区二区小视频 | 亚洲欧美aⅴ | 国产乱码精品一区二三赶尸艳谈 | 天天av天天好逼 | 欧美精品1区 | 91在线视频免费观看 | 亚洲精品一区二区在线观看 | www.操com | 欧美在线| 日本久久久久久 | 国产激情视频网站 | 荷兰欧美一级毛片 | 人人做人人澡人人爽欧美 | 精品伦精品一区二区三区视频 | 四虎成人免费电影 | www.色.com| 中文字幕免费 | 亚洲精品成人网 | 日韩一级免费大片 | 日本一区二区三区四区 | 成人教育av | 96国产精品久久久久aⅴ四区 | 伊人伊成久久人综合网站 |