1
1
import pytest
2
2
import sys
3
3
4
+
4
5
def pytest_addoption (parser ):
5
6
group = parser .getgroup ("debugconfig" )
6
7
group .addoption ('--setuponly' , '--setup-only' , action = "store_true" ,
7
- help = "only setup fixtures, don't execute the tests." )
8
+ help = "only setup fixtures, don't execute the tests." )
8
9
group .addoption ('--setupshow' , '--setup-show' , action = "store_true" ,
9
- help = "show setup fixtures while executing the tests." )
10
+ help = "show setup fixtures while executing the tests." )
11
+
10
12
11
13
@pytest .hookimpl (hookwrapper = True )
12
14
def pytest_fixture_setup (fixturedef , request ):
@@ -20,11 +22,13 @@ def pytest_fixture_setup(fixturedef, request):
20
22
if callable (fixturedef .ids ):
21
23
fixturedef .cached_param = fixturedef .ids (request .param )
22
24
else :
23
- fixturedef .cached_param = fixturedef .ids [request .param_index ]
25
+ fixturedef .cached_param = fixturedef .ids [
26
+ request .param_index ]
24
27
else :
25
28
fixturedef .cached_param = request .param
26
29
_show_fixture_action (fixturedef , 'SETUP' )
27
30
31
+
28
32
def pytest_fixture_post_finalizer (fixturedef ):
29
33
if hasattr (fixturedef , "cached_result" ):
30
34
config = fixturedef ._fixturemanager .config
@@ -33,6 +37,7 @@ def pytest_fixture_post_finalizer(fixturedef):
33
37
if hasattr (fixturedef , "cached_param" ):
34
38
del fixturedef .cached_param
35
39
40
+
36
41
def _show_fixture_action (fixturedef , msg ):
37
42
config = fixturedef ._fixturemanager .config
38
43
capman = config .pluginmanager .getplugin ('capturemanager' )
@@ -60,6 +65,7 @@ def _show_fixture_action(fixturedef, msg):
60
65
sys .stdout .write (out )
61
66
sys .stderr .write (err )
62
67
68
+
63
69
@pytest .hookimpl (tryfirst = True )
64
70
def pytest_cmdline_main (config ):
65
71
if config .option .setuponly :
0 commit comments