码迷,mamicode.com
首页 > 其他好文 > 详细

test_login(ddt)

时间:2021-02-26 13:10:21      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:登录   test   scope   class   login   color   use   imp   from   

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("我是模块下的测试用例")

 

test_login(ddt)

标签:登录   test   scope   class   login   color   use   imp   from   

原文地址:https://www.cnblogs.com/zhang-ping1205/p/14448487.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!