单元测试框架unittest框架 ,执行run 报错:ModuleNotFoundError: No module named ‘pytest‘

单元测试框架unittest框架 ,执行run 报错

报错:ModuleNotFoundError: No module named ‘pytest’

login.py中包含如下代码:
# 登录功能代码
def login_check(username=None,password=None):
    if username != None and password != None:
        if username== 'python33' and password=='lemonban':
            return {"code": 0, "msg": "登录成功"}
        else:
            return {"code": 1, "msg": "账号或密码不正确"}
    else:
        return {"code":1,"msg":"所有参数不能为空"}



#测试unittest.py中代码如下:
import unittest
from login import login_check

class TestLogin(unittest.TestCase): #一定要继承
    def test_login_success(self):
        actual=login_check("python33","lemonban")
        #断言
        self.assertEqual({"code": 0, "msg": "登录成功"},actual)

    def test_login_err_usrname(self):
        actual2=login_

你可能感兴趣的:(单元测试,python,pycharm)