使用Pytest框架做自动化测试时,使用Pytest_check模块进行断言,但是运行时会提示一个错误,如下所示:
============================== warnings summary ===============================
..\venv\lib\site-packages\_pytest\config\__init__.py:1114
C:\Users\Administrator\Desktop\jiekou\venv\lib\site-packages\_pytest\config\__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: pytest_check
self._mark_plugins_for_rewrite(hook)
-- Docs: https://docs.pytest.org/en/stable/warnings.html
解决办法:
pytest.main(['-v', '-s' ,'-W','ignore:Module already imported:pytest.PytestWarning'])
只需要加上该命令就忽略次错误:'-W','ignore:Module already imported:pytest.PytestWarning'