• run类中方法级别的setup和teardown.py


    import pytest
    import requests
    class TestCase(object):
    def test_case_01(self):
    """再执行三"""
    assert 1

    def test_case_02(self):
    """再执行六"""
    assert {"title":"v2ex"} != {"title":"V2EX"}

    def test_case_03(self):
    """再执行九"""
    assert 1

    def setup_class(self):
    """先执行一setup_class 类级别的setup"""
    print("类级别的setup")

    def teardown_class(self):
    """再执行十一teardown_class 类级别的teardown"""
    print("类级别的teardown")

    def setup_method(self):
    """再执行二setup_method 类中方法级别的setup"""
    """再执行五setup_method 类中方法级别的setup"""
    """再执行八setup_method 类中方法级别的setup"""
    print("类中方法级别的setup")

    def teardown_method(self):
    """再执行四teardown_method 类中方法级别的teardown"""
    """再执行七teardown_method 类中方法级别的teardown"""
    """再执行十teardown_method 类中方法级别的teardown"""
    print("类中方法级别的teardown ")

    if __name__ == '__main__':
    pytest.main(["-s","run类中方法级别的setup和teardown.py"])
  • 相关阅读:
    angularJS
    WebSocket通信协议
    重写ajax方法实现异步请求session过期时跳转登录页面
    npm(cnpm)介绍(安装gulp)
    grunt安装与配置
    前端学习之jquery
    前端基础之CSS
    前端基础html
    激活
    socket 网络通信(基于tcp协议)以及粘包解决方案
  • 原文地址:https://www.cnblogs.com/zhang-da/p/12219133.html
Copyright © 2020-2023  润新知