推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
larkifly
V2EX  ›  Python

最近在玩 Jenkins,使用 nose+coverage,如何查看 webpy 的测试用例对 webpy 所有接口代码的覆盖率了。

  •  
  •   larkifly · Nov 24, 2015 · 2795 views
    This topic created in 3957 days ago, the information mentioned may be changed or developed.

    打算使用 nose+coverage 做自动化测试,并且查看测试用例对 webpy 程序的覆盖率是多少。目前测试用例是这么写的

    from paste.fixture import TestApp
    from nose.tools import *
    from index import app
    
    class TestIndex():
        def test_index(self):
            middleware = []
            testapp = TestApp(app.wsgifunc(*middleware))
            r = testapp.get('/')
            assert_equal(r.status, 200)
    
        def test_login(self):
            middleware = []
            testapp = TestApp(app.wsgifunc(*middleware))
            r = testapp.get('/login')
            assert_equal(r.status, 200)
    

    但是覆盖率的结果是这样的
    Mou icon
    可以看到,测试覆盖率都是 test_index 这个文件本身,而不是引用的 index.py 。

    我要看 test_index.py 里的测试用例对 index.py 里的接口覆盖率,应该如何编写测试用例。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   839 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 20:37 · PVG 04:37 · LAX 13:37 · JFK 16:37
    ♥ Do have faith in what you're doing.