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