@@ -29,7 +29,6 @@ def pytest_runtest_makereport(self, item, call):
2929 )
3030
3131 if report .when == "setup" :
32-
3332 # when function pytest_setup is called,
3433 # test item session will be started in RP
3534 PyTestService .start_pytest_item (item )
@@ -58,45 +57,38 @@ def pytest_runtest_makereport(self, item, call):
5857
5958
6059def 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 )
60+ PyTestService .init_service (
61+ project = session .config .getini ("rp_project" ),
62+ endpoint = session .config .getini ("rp_endpoint" ),
63+ uuid = session .config .getini ("rp_uuid" ),
64+ )
65+
66+ PyTestService .start_launch (
67+ session .config .option .rp_launch ,
68+ tags = session .config .getini ("rp_launch_tags" ),
69+ description = session .config .getini ("rp_launch_description" ),
70+ )
7671
7772
7873def 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" )
74+ # FixMe: currently method of RP api takes the string parameter
75+ # so it is hardcoded
76+ PyTestService .finish_launch (status = "RP_Launch" )
8477
8578
8679def 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 ()
80+ if not config .option .rp_launch :
81+ config .option .rp_launch = config .getini ("rp_launch" )
9182
92- if hasattr (config , "_reporter" ):
93- config .pluginmanager .register (config ._reporter )
83+ # set Pytest_Reporter and configure it
84+ config ._reporter = RP_Report_Listener ()
85+
86+ if hasattr (config , "_reporter" ):
87+ config .pluginmanager .register (config ._reporter )
9488
9589
9690def pytest_unconfigure (config ):
97- rp_launch = config .getoption ("rp_launch" )
98- if rp_launch :
99- PyTestService .terminate_service ()
91+ PyTestService .terminate_service ()
10092
10193 if hasattr (config , "_reporter" ):
10294 reporter = config ._reporter
@@ -111,21 +103,31 @@ def pytest_addoption(parser):
111103 "--rp-launch" ,
112104 action = "store" ,
113105 dest = "rp_launch" ,
114- help = "The Launch name for RP " )
106+ help = "Launch name (overrides rp_launch config option) " )
115107
116108 parser .addini (
117109 "rp_uuid" ,
118- help = "Uid of RP user " )
110+ help = "UUID " )
119111
120112 parser .addini (
121113 "rp_endpoint" ,
122- help = "RP server " )
114+ help = "Server endpoint " )
123115
124116 parser .addini (
125117 "rp_project" ,
126- help = "RP Project" )
118+ help = "Project name" )
119+
120+ parser .addini (
121+ "rp_launch" ,
122+ default = "Pytest Launch" ,
123+ help = "Launch name" )
127124
128125 parser .addini (
129126 "rp_launch_tags" ,
130127 type = "args" ,
131- help = "Tags for of RP Launch, i.e Perfomance Regression" )
128+ help = "Launch tags, i.e Performance Regression" )
129+
130+ parser .addini (
131+ "rp_launch_description" ,
132+ default = "" ,
133+ help = "Launch description" )
0 commit comments