firmware:

import pytest
import requests
pytest.fixture @ () 
DEF the Login ():
Print ( "Log .......")

DEF test_index1 (the Login):
"" "to log in before test" ""
Print ( "Home 1 ..... ..... ")

DEF test_index2 (the Login):
" "" before the test be logged in "" "
Print (" Home .......... 2 ")

IF __name__ == '__main__':
pytest. main ([ "- s", "test_case.py"])

result:

=========================================================== test session starts ============================================================
platform win32 -- Python 3.6.6, pytest-5.3.2, py-1.8.1, pluggy-0.13.1 -- c:\python36\python.exe
cachedir: .pytest_cache
rootdir: D:\s27\day68, inifile: pytest.ini, testpaths: ./scripts
collected 2 items

scripts / test_case.py :: test_index1 Log .......
Home .......... 1
PASSED
scripts / test_case.py :: test_index2 Log .......
Home 2 ... .......
PASSED

============================================================= warnings summary =============================================================
scripts\test_case.py:93
D:\s27\day68\scripts\test_case.py:93: DeprecationWarning: invalid escape sequence \s
"""

-- Docs: https://docs.pytest.org/en/latest/warnings.html
======================================================= 2 passed, 1 warning in 0.51s =======================================================

Guess you like

Origin www.cnblogs.com/zhang-da/p/12220903.html