pytest框架,使用print在控制台输入


代码示例:

import pytest
@pytest.fixture(autouse=True,scope='session') #autouse=True,scope='session'
def session_scope():
print("#######################0")
yield
print("~~~~~~~~~~~~~~~~~~~~~~~1")
@pytest.mark.add
#@pytest.mark.usefixtures("session_scope")
class Test_case():
def test_one(self):
print("测试用例")

if __name__ == '__main__':
pytest.main(["-m","add"])

设置:
第一种方法:

1.打开pycharm右上角Edit Config....

2.选择python tests-----py.test

3.设置代码路径,名称随意,python版本随意,然后点击保存

4.验证成功

第二种方法:

在运行时候加个-s就行了,例如 pytest.main(["-m","add",“-s”])




					


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM