zoukankan      html  css  js  c++  java
  • pytest框架(五)

    代码示例一

     1 # coding=utf-8
     2 import pytest
     3 
     4 
     5 @pytest.fixture()
     6 def login():
     7     print("输入账号,密码先登录")
     8 
     9 
    10 def test_s1(login):
    11     print("用例1:登录之后其他动作111")
    12 
    13 
    14 def test_s2():  # 不传login
    15     print("用例2:不需要登录,操作222")
    16 
    17 
    18 def test_s3(login):
    19     print("用例3:登录之后其他动作333")
    20 
    21 
    22 if __name__ == "__main__":
    23     pytest.main(['-s', 'test_fixture.py'])

    代码示例二

    conftest.py

    #coding=utf-8
    import pytest
    
    @pytest.fixture()
    def login():
        print("输入账号密码,登录")

    test_fix1.py

    # coding=utf-8
    import pytest
    
    
    def test_s1(login):
        print("用例1:登录之后其它动作111")
    
    
    def test_s2():  # 不传login
        print("用例2:不需要登录,操作222")
    
    
    def test_s3(login):
        print("用例3:登录之后其它动作333")
    
    
    if __name__ == "__main__":
        pytest.main(["-s", "test_fix1.py"])

    test_fix2.py

    # coding:utf-8
    import pytest
    
    
    def test_s4(login):
        print("用例4:登录之后其它动作444")
    
    
    def test_s5():  # 不传login
        print("用例5:不需要登录,操作555")
    
    
    if __name__ == "__main__":
        pytest.main(["-s", "test_fix2.py"])
  • 相关阅读:
    Python:三元运算
    SaltStack部署服务及配置管理apache+php-第二篇
    SaltStack介绍及简单配置-第一篇
    git基础常用维护命令
    MySQL设置只读模式
    运维杂记-05
    Tomcat的配置,设置内存,获取用户IP
    Linux系统巡检项目
    Redis维护
    nginx配置文件说明
  • 原文地址:https://www.cnblogs.com/loveapple/p/9527940.html
Copyright © 2011-2022 走看看