pytest to skip a specified test or module

Reference Allure official documents , pytest official documents

Implement setup / teardown

 

1. Test runs with the specified tag

@ Pytest.mark.tags, tags can be custom here

Command line: pytest -v -m 'tags' 

2. Skip the specified test

pytest.mark.skip @ (reason = " Expired " ) # skip this test 
DEF test_app_logic ():
     '' ' 
    use described: the logical test 
    ' '' 
    Print ( ' logical test ' ) 
    the time.sleep ( . 1 )
     Assert . 1 = = 1

3. Skip specified module

The actual test, when @ pytest.importorskip ( "module name", minversion = "1.5") in which the decorator module, which module will be skipped, the module name just write no impact.

pytest.importorskip @ ( " test_ltcs " , MinVersion = " for 1.5 " ) 
@ allure.step ( ' check UI name: {0} open ' )
 DEF ui_check (Tips):
     return Tips

4. Skip conditions specified by Example

pytest.mark.skipif @ ( ' ! = 2 + 2. 5 ' , reason = ' conditional trigger ' )
 DEF test_skip_by_triggered_condition ():
     Assert 2 + 2. 4 ==

 

Guess you like

Origin www.cnblogs.com/sc912/p/11369651.html