ValueError: option names {'--alluredir'} already added 报错
2024-09-08 11:01:36
运行测试用例
import pytest from WXP2P_2.test_data2.login_case import logindata_error1,logindata_error2,logindata_right class TestLogin: """测试登录""" @pytest.mark.parametrize("data",logindata_error1)#装饰测试用例。 @pytest.mark.wrong def test_error1(self,data,int_start): """错误信息""" int_start[0].login(data["use"],data["password"]) try: assert (int_start[0].error_value()==data["expected"]) print("测试用例通过,预期结果{}与实际结果{}一致".format(data["expected"],int_start[0].error_value())) except AssertionError as e: print("用例失败") raise e finally: int_start[0].clear()#清空输入框 # Login().login(data["use"], data["password"])#错误示范,这种调用方法,会多次打开浏览器 # Login().clear()#错误示范,这种调用方法,会多次打开网页 # @pytest.mark.parametrize("data",logindata_error2) # def test_error2(self, data): # """错误信息""" # self.login.login(data["use"], data["password"]) # try: # assert (self.login.error_value1() == data["expected"]) # print("测试用例通过,预期结果{}与实际结果{}一致".format(data["expected"], self.login.error_value1())) # except AssertionError as e: # print("用例失败") # raise e # finally: # self.login.clear() # 清空输入框 # @pytest.mark.ok # @pytest.mark.parametrize("data",logindata_right)#装饰测试用例 # def test_right(self,data): # """正确的信息登录""" # self.login.login(data["use"], data["password"]) # try: # assert (data["expected"] in self.login.right_value()) # print("测试用例通过,预期结果{}与实际结果{}一致".format(data["expected"], self.login.right_value())) # except AssertionError as e: # print("用例失败") # raise e # # Login().login(data["use"], data["password"])#错误示范,这种调用方法,会多次打开网页 if __name__ == '__main__': pytest.main(["-m wrong","-s"])
执行结果
Traceback (most recent call last): File "D:/WX_P2P_ITEM/WXP2P_2/test_login.py", line 46, in <module> pytest.main(["-m wrong","-s"]) File "D:\Python\lib\site-packages\_pytest\config\__init__.py", line 60, in main config = _prepareconfig(args, plugins) File "D:\Python\lib\site-packages\_pytest\config\__init__.py", line 204, in _prepareconfig pluginmanager=pluginmanager, args=args File "D:\Python\lib\site-packages\pluggy\hooks.py", line 289, in __call__ return self._hookexec(self, self.get_hookimpls(), kwargs) File "D:\Python\lib\site-packages\pluggy\manager.py", line 68, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File "D:\Python\lib\site-packages\pluggy\manager.py", line 62, in <lambda> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, File "D:\Python\lib\site-packages\pluggy\callers.py", line 203, in _multicall gen.send(outcome) File "D:\Python\lib\site-packages\_pytest\helpconfig.py", line 93, in pytest_cmdline_parse config = outcome.get_result() File "D:\Python\lib\site-packages\pluggy\callers.py", line 80, in get_result raise ex[1].with_traceback(ex[2]) File "D:\Python\lib\site-packages\pluggy\callers.py", line 187, in _multicall res = hook_impl.function(*args) File "D:\Python\lib\site-packages\_pytest\config\__init__.py", line 684, in pytest_cmdline_parse self.parse(args) File "D:\Python\lib\site-packages\_pytest\config\__init__.py", line 901, in parse self._preparse(args, addopts=addopts) File "D:\Python\lib\site-packages\_pytest\config\__init__.py", line 846, in _preparse self.pluginmanager.load_setuptools_entrypoints("pytest11") File "D:\Python\lib\site-packages\pluggy\manager.py", line 282, in load_setuptools_entrypoints self.register(plugin, name=ep.name) File "D:\Python\lib\site-packages\_pytest\config\__init__.py", line 318, in register ret = super(PytestPluginManager, self).register(plugin, name) File "D:\Python\lib\site-packages\pluggy\manager.py", line 102, in register hook._maybe_apply_history(hookimpl) File "D:\Python\lib\site-packages\pluggy\hooks.py", line 336, in _maybe_apply_history res = self._hookexec(self, [method], kwargs) File "D:\Python\lib\site-packages\pluggy\manager.py", line 68, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File "D:\Python\lib\site-packages\pluggy\manager.py", line 62, in <lambda> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, File "D:\Python\lib\site-packages\pluggy\callers.py", line 208, in _multicall return outcome.get_result() File "D:\Python\lib\site-packages\pluggy\callers.py", line 80, in get_result raise ex[1].with_traceback(ex[2]) File "D:\Python\lib\site-packages\pluggy\callers.py", line 187, in _multicall res = hook_impl.function(*args) File "D:\Python\lib\site-packages\allure_pytest\plugin.py", line 21, in pytest_addoption help="Generate Allure report in the specified directory (may not exist)") File "D:\Python\lib\site-packages\_pytest\config\argparsing.py", line 303, in addoption raise ValueError("option names %s already added" % conflict) ValueError: option names {'--alluredir'} already added
这是因为pytest-allure-adaptor与allure-pytest的alluredir都被引用造成冲突
需要卸载pytest-allure-adaptor
卸载完成后,再执行测试模块
============================= test session starts ============================= platform win32 -- Python 3.6.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0 rootdir: D:\WX_P2P_ITEM\WXP2P_2 plugins: allure-pytest-2.6.5 collected 5 items / 3 deselected / 2 selected test_login.py 测试用例通过,预期结果请输入正确的手机号与实际结果请输入正确的手机号一致 .测试用例通过,预期结果请输入手机号与实际结果请输入手机号一致 .
最新文章
- Codeforces Round #344 (Div. 2) A. Interview
- LINQ系列:Linq to Object限制操作符
- Java获取XML节点总结之读取XML文档节点
- PHP如何判断一个数组是一维数组或者是二维数组?用什么函数?
- 菜鸟学自动化测试(八)----selenium 2.0环境搭建(基于maven)
- span width无效
- TYVJ P1034 尼克的任务 Label:倒推dp
- github 修改fork的代码之后如何提交代码并pull request
- MongoDB 数据类型
- Mac使用指南
- struts2+jquery+ajax实现上传&;&;校验实例
- java cmd常用命令
- 工作中小知识点汇总(sql)
- 将json的时间格式转换成正常的时间格式
- SCRIPT7002: XMLHttpRequest: 网络错误 0x2ef3, 由于出现错误 00002ef3&;nbsp
- 在Python3.5中使用 The del.icio.us API
- 《HelloGitHub》第 29 期
- Linux下删除乱码文件
- ASP.NET Core使用log4net记录日志
- React child