最新公告
  • 欢迎您光临IO源码网,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入我们
  • Python Testing with pytest PDF 下载

    失效链接处理 Python Testing with pytest PDF 下载


    本站整理下载:
    链接:https://pan.baidu.com/s/1nQ21OTaWrFhsPVNvH4Z8sA 
    提取码:82ts 
    相关截图:
    主要内容:
    Chapter 1
    Getting Started with pytest
    This is a test:
    ch1/test_one.py
    ​ ​def​ test_passing():
    ​ ​assert​ (1, 2, 3) == (1, 2, 3)
    This is what it looks like when it’s run:
    ​ ​$ ​​cd​​ ​​/path/to/code/ch1​
    ​ ​$ ​​pytest​​ ​​test_one.py​
    ​ ===================== test session starts ======================
    ​ collected 1 items
    ​ test_one.py .
    ​ =================== 1 passed in 0.01 seconds ===================
    The dot after test_one.py means that one test was run and it passed. If you need more
    information, you can use -v or –verbose:
    ​ ​$ ​​pytest​​ ​​-v​​ ​​test_one.py​
    ​ ===================== test session starts ======================
    ​ collected 1 items
    ​ test_one.py::test_passing PASSED
    ​ =================== 1 passed in 0.01 seconds ===================
    If you have a color terminal, the PASSED and bottom line are green. It’s nice.
    This is a failing test:
    ch1/test_two.py
    ​ ​def​ test_failing():
    ​ ​assert​ (1, 2, 3) == (3, 2, 1)
    The way pytest shows you test failures is one of the many reasons developers love pytest. Let’s
    watch this fail:
    ​ ​$ ​​pytest​​ ​​test_two.py​
    (1)
    ​ ===================== test session starts ======================
    ​ collected 1 items
    ​ test_two.py F
    ​ =========================== FAILURES ===========================
    ​ _________________________ test_failing _________________________
    ​ def test_failing():
    ​ > assert (1, 2, 3) == (3, 2, 1)
    ​ E assert (1, 2, 3) == (3, 2, 1)
    ​ E At index 0 diff: 1 != 3
    ​ E Use -v to get the full diff
    ​ test_two.py:2: AssertionError
    ​ =================== 1 failed in 0.04 seconds ===================
    Cool. The failing test, test_failing, gets its own section to show us why it failed. And pytest tells
    us exactly what the first failure is: index 0 is a mismatch. Much of this is in red to make it really
    stand out (if you’ve got a color terminal). That’s already a lot of information, but there’s a line
    that says Use -v to get the full diff. Let’s do that:
    ​ ​$ ​​pytest​​ ​​-v​​ ​​test_two.py​
    ​ ===================== test session starts ======================
    ​ collected 1 items
    ​ test_two.py::test_failing FAILED
    ​ =========================== FAILURES ===========================
    ​ _________________________ test_failing _________________________
    ​ def test_failing():
    ​ > assert (1, 2, 3) == (3, 2, 1)
    ​ E assert (1, 2, 3) == (3, 2, 1)
    ​ E At index 0 diff: 1 != 3
    ​ E Full diff:
    ​ E – (1, 2, 3)
    ​ E ? ^ ^
    ​ E + (3, 2, 1)
    ​ E ? ^ ^
    ​ test_two.py:2: AssertionError
    ​ =================== 1 failed in 0.04 seconds ===================
    (2)
    Wow. pytest adds little carets (^) to show us exactly what’s different.
    If you’re already impressed with how easy it is to write, read, and run tests with pytest, and how
    easy it is to read the output to see where the tests fail, well, you ain’t seen nothing yet. There’s
    lots more where that came from. Stick around and let me show you why I think pytest is the
    absolute best test framework available.
    In the rest of this chapter, you’ll install pytest, look at different ways to run it, and run through
    some of the most often used command-line options. In future chapters, you’ll learn how to write
    test functions that maximize the power of pytest, how to pull setup code into setup and teardown
    sections called fixtures, and how to use fixtures and plugins to really supercharge your software
    testing.
    But first, I have an apology. I’m sorry that the test, assert (1, 2, 3) == (3, 2, 1), is so boring.
    Snore. No one would write a test like that in real life. Software tests are comprised of code that
    tests other software that you aren’t always positive will work. And (1, 2, 3) == (1, 2, 3) will
    always work. That’s why we won’t use overly silly tests like this in the rest of the book. We’ll
    look at tests for a real software project. We’ll use an example project called Tasks that needs
    some test code. Hopefully it’s simple enough to be easy to understand, but not so simple as to be
    boring.
    Another great use of software tests is to test your assumptions about how the software under test
    works, which can include testing your understanding of third-party modules and packages, and
    even builtin Python data structures. The Tasks project uses a structure called Task, which is
    based on the namedtuple factory method, which is part of the standard library. The Task structure
    is used as a data structure to pass information between the UI and the API. For the rest of this
    chapter, I’ll use Task to demonstrate running pytest and using some frequently used command-
    line options.

     

    *** 次数:10600 已用完,请联系开发者***
    1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服!384324621@qq.com
    2. 本站不保证所提供下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理,有奖励!
    3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
    4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有★币奖励和额外收入!

    IO 源码网 » Python Testing with pytest PDF 下载

    常见问题FAQ

    免费下载或者VIP会员专享资源能否直接商用?
    本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
    提示下载完但解压或打开不了?
    最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用百度网盘软件或迅雷下载。若排除这种情况,可在对应资源底部留言,或 联络我们.。
    找不到素材资源介绍文章里的示例图片?
    对于PPT,KEY,Mockups,APP,网页模版等类型的素材,文章内用于介绍的图片通常并不包含在对应可供下载素材包内。这些相关商业图片需另外购买,且本站不负责(也没有办法)找到出处。 同样地一些字体文件也是这种情况,但部分素材会在素材包内有一份字体下载链接清单。
    IO源码吧
    一个高级程序员模板开发平台

    发表评论

    • 157会员总数(位)
    • 12105资源总数(个)
    • 97本周发布(个)
    • 0 今日发布(个)
    • 537稳定运行(天)

    提供最优质的资源集合

    立即查看 了解详情