@@ -58,45 +58,38 @@ def pytest_runtest_makereport(self, item, call):
5858
5959
6060def pytest_sessionstart (session ):
61- config = session .config
62- if config .option .rp_launch :
63- # get config parameters if rp_launch option is set
64- rp_uuid = config .getini ("rp_uuid" )
65- rp_project = config .getini ("rp_project" )
66- rp_endpoint = config .getini ("rp_endpoint" )
67- rp_launch_tags = config .getini ("rp_launch_tags" )
68- # initialize PyTest
69- PyTestService .init_service (
70- project = rp_project ,
71- endpoint = rp_endpoint ,
72- uuid = rp_uuid )
73- launch_name = config .getoption ("rp_launch" )
74-
75- PyTestService .start_launch (launch_name , tags = rp_launch_tags )
61+ PyTestService .init_service (
62+ project = session .config .getini ("rp_project" ),
63+ endpoint = session .config .getini ("rp_endpoint" ),
64+ uuid = session .config .getini ("rp_uuid" ),
65+ )
66+
67+ PyTestService .start_launch (
68+ session .config .option .rp_launch ,
69+ tags = session .config .getini ("rp_launch_tags" ),
70+ description = session .config .getini ("rp_launch_description" ),
71+ )
7672
7773
7874def pytest_sessionfinish (session ):
79- config = session .config
80- if config .option .rp_launch :
81- # FixMe: currently method of RP api takes the string parameter
82- # so it is hardcoded
83- PyTestService .finish_launch (status = "RP_Launch" )
75+ # FixMe: currently method of RP api takes the string parameter
76+ # so it is hardcoded
77+ PyTestService .finish_launch (status = "RP_Launch" )
8478
8579
8680def pytest_configure (config ):
87- rp_launch = config .getoption ("rp_launch" )
88- if rp_launch :
89- # set Pytest_Reporter and configure it
90- config ._reporter = RP_Report_Listener ()
81+ if not config .option .rp_launch :
82+ config .option .rp_launch = config .getini ("rp_launch" )
83+
84+ # set Pytest_Reporter and configure it
85+ config ._reporter = RP_Report_Listener ()
9186
92- if hasattr (config , "_reporter" ):
93- config .pluginmanager .register (config ._reporter )
87+ if hasattr (config , "_reporter" ):
88+ config .pluginmanager .register (config ._reporter )
9489
9590
9691def pytest_unconfigure (config ):
97- rp_launch = config .getoption ("rp_launch" )
98- if rp_launch :
99- PyTestService .terminate_service ()
92+ PyTestService .terminate_service ()
10093
10194 if hasattr (config , "_reporter" ):
10295 reporter = config ._reporter
@@ -111,21 +104,31 @@ def pytest_addoption(parser):
111104 "--rp-launch" ,
112105 action = "store" ,
113106 dest = "rp_launch" ,
114- help = "The Launch name for RP " )
107+ help = "Launch name (overrides rp_launch config option) " )
115108
116109 parser .addini (
117110 "rp_uuid" ,
118- help = "Uid of RP user " )
111+ help = "UUID " )
119112
120113 parser .addini (
121114 "rp_endpoint" ,
122- help = "RP server " )
115+ help = "Server endpoint " )
123116
124117 parser .addini (
125118 "rp_project" ,
126- help = "RP Project" )
119+ help = "Project name" )
120+
121+ parser .addini (
122+ "rp_launch" ,
123+ default = "Pytest Launch" ,
124+ help = "Launch name" )
127125
128126 parser .addini (
129127 "rp_launch_tags" ,
130128 type = "args" ,
131- help = "Tags for of RP Launch, i.e Perfomance Regression" )
129+ help = "Launch tags, i.e Performance Regression" )
130+
131+ parser .addini (
132+ "rp_launch_description" ,
133+ default = "" ,
134+ help = "Launch description" )
0 commit comments