zoukankan      html  css  js  c++  java
  • pytest钩子函数--pytest_runtest_makereport获取结果

    1、在项目根目录添加config.py

    2、from _pytest import runner======》pytest_runtest_makereport

    3、item 是测试用例,call是测试步骤

    import pytest
    #钩子函数
    @pytest.hookimpl(hookwrapper=True,tryfirst=True)
    def pytest_runtest_makereport(item,call):
        out =yield
        report = out.get_result()
        print('测试报告:%s' % report)
        print('步骤:%s' % report.when)
        print('nodeid:%s' % report.nodeid)
        print('description:%s' % str(item.function.__doc__))
        print(('运行结果: %s' % report.outcome))
        if report.when=='call':
            print("call通过")

    4、测试案例

    @pytest.mark.parametrize("data", [("zhangsan")])
    def test_08(self,data):
            print(data)

    5、执行结果

     6、执行过程分为3个阶段

    setup--call--teardown

    上班求生存,下班求发展
  • 相关阅读:
    简单的sql注入3
    简单的sql注入2
    简单的sql注入1
    python安装request及更新pip
    kali linux上安装ssh
    看起来有点难
    猫抓老鼠
    头有点大
    貌似有点难
    这个看起来有点简单!
  • 原文地址:https://www.cnblogs.com/ljf520hj/p/15479137.html
Copyright © 2011-2022 走看看