88from .service import PyTestServiceClass
99from .listener import RPReportListener
1010
11+ try :
12+ # This try/except can go away once we support pytest >= 3.3
13+ import _pytest .logging
14+ PYTEST_HAS_LOGGING_PLUGIN = True
15+ except ImportError :
16+ PYTEST_HAS_LOGGING_PLUGIN = False
17+
1118
1219def is_master (config ):
1320 """
@@ -25,6 +32,7 @@ def pytest_configure_node(node):
2532def pytest_sessionstart (session ):
2633 if session .config .getoption ('--collect-only' , default = False ) is True :
2734 return
35+
2836 if is_master (session .config ):
2937 session .config .py_test_service .init_service (
3038 project = session .config .getini ('rp_project' ),
@@ -65,6 +73,8 @@ def pytest_sessionfinish(session):
6573def pytest_configure (config ):
6674 if not config .option .rp_launch :
6775 config .option .rp_launch = config .getini ('rp_launch' )
76+ if not config .option .rp_launch_description :
77+ config .option .rp_launch_description = config .getini ('rp_launch_description' )
6878
6979 if is_master (config ):
7080 config .py_test_service = PyTestServiceClass ()
@@ -73,7 +83,20 @@ def pytest_configure(config):
7383 config .py_test_service .RP .listener .start ()
7484
7585 # set Pytest_Reporter and configure it
76- config ._reporter = RPReportListener (config .py_test_service )
86+
87+ if PYTEST_HAS_LOGGING_PLUGIN :
88+ # This check can go away once we support pytest >= 3.3
89+ try :
90+ config ._reporter = RPReportListener (
91+ config .py_test_service ,
92+ _pytest .logging .get_actual_log_level (config , 'rp_log_level' )
93+ )
94+ except TypeError :
95+ # No log level set either in INI or CLI
96+ config ._reporter = RPReportListener (config .py_test_service )
97+ else :
98+ config ._reporter = RPReportListener (config .py_test_service )
99+
77100 if hasattr (config , '_reporter' ):
78101 config .pluginmanager .register (config ._reporter )
79102
@@ -95,6 +118,24 @@ def pytest_addoption(parser):
95118 action = 'store' ,
96119 dest = 'rp_launch' ,
97120 help = 'Launch name (overrides rp_launch config option)' )
121+ group .addoption (
122+ '--rp-launch-description' ,
123+ action = 'store' ,
124+ dest = 'rp_launch_description' ,
125+ help = 'Launch description (overrides rp_launch_description config option)' )
126+
127+ if PYTEST_HAS_LOGGING_PLUGIN :
128+ group .addoption (
129+ '--rp-log-level' ,
130+ dest = 'rp_log_level' ,
131+ default = logging .NOTSET ,
132+ help = 'Logging level for automated log records reporting'
133+ )
134+ parser .addini (
135+ 'rp_log_level' ,
136+ default = logging .NOTSET ,
137+ help = 'Logging level for automated log records reporting'
138+ )
98139
99140 parser .addini (
100141 'rp_uuid' ,
@@ -137,4 +178,4 @@ def pytest_addoption(parser):
137178 parser .addini (
138179 'rp_ignore_tags' ,
139180 type = 'args' ,
140- help = 'Ignore specified pytest markers, i.e parametrize' )
181+ help = 'Ignore specified pytest markers, i.e parametrize' )
0 commit comments