• test_login(ddt)


    import pytest
    from login import login_check
    
    datas = [
        {"user":'python37', "passwd": 'lemonban', "check": {"code": 0, "msg": "登录成功"} },
        {"user":'python37', "passwd": 'lemonban666', "check": {"code": 1, "msg": "账号或密码不正确"} },
        {"user": 'python370', "passwd": 'lemonban', "check": {"code": 1, "msg": "账号或密码不正确"}},
        {"user": None, "passwd": 'lemonban', "check": {"code": 1, "msg": "所有的参数不能为空"}},
        {"user": 'python37', "passwd": None, "check": {"code": 1, "msg": "所有的参数不能为空"}}
    ]
    
    
    
    
    # @pytest.mark.usefixtures("class_fix")  # 调用函数名为class_fix的fixture.
    @pytest.mark.usefixtures("hello2")   # 调用函数名为hello的fixture.
    class TestLogin:
    
        @pytest.mark.parametrize("case",datas)
        def test_login(self,case):
            actual = login_check(case["user"], case["passwd"])
            assert actual == case["check"]
    
        # @pytest.fixture(scope="class", autouse=True)
        # def hello(self):
        #     # 前置准备工作的代码
        #     print("一条测试用例开始执行")
        #     print("6666666")
        #     yield
        #     # 后置清理工作的代码
        #     print("一条测试用例执行结束")
    
    
    @pytest.mark.usefixtures("hello")
    def test_hello_world():
        print("我是模块下的测试用例")
  • 相关阅读:
    Swift # Apple Pay集成
    GitHub Top 100 简介
    一些常用算法
    CocoaPods 建立私有仓库
    安装 CocoaPods & Alcatraz
    iOS程序 # 启动过程
    Apache & WebDav 配置(二)
    SVN & Git (二)
    SVN & Git (一)
    poj 3169 Layout (差分约束)
  • 原文地址:https://www.cnblogs.com/zhang-ping1205/p/14448487.html
Copyright © 2020-2023  润新知