@@ -190,7 +190,19 @@ def pytest_addhooks(pluginmanager):
190190
191191@pytest .hookimpl (trylast = True )
192192def pytest_configure (config ):
193- if config .getoption ("dist" ) != "no" and not config .getvalue ("collectonly" ):
193+ config_line = (
194+ "xdist_group: specify group for tests should run in same session."
195+ "in relation to one another. Provided by pytest-xdist."
196+ )
197+ config .addinivalue_line ("markers" , config_line )
198+
199+ # Skip this plugin entirely when only doing collection.
200+ if config .getvalue ("collectonly" ):
201+ return
202+
203+ # Create the distributed session in case we have a valid distribution
204+ # mode and test environments.
205+ if config .getoption ("dist" ) != "no" and config .getoption ("tx" ):
194206 from xdist .dsession import DSession
195207
196208 session = DSession (config )
@@ -199,6 +211,7 @@ def pytest_configure(config):
199211 if tr :
200212 tr .showfspath = False
201213
214+ # Deprecation warnings for deprecated command-line/configuration options.
202215 if config .getoption ("looponfail" , None ) or config .getini ("looponfailroots" ):
203216 warning = DeprecationWarning (
204217 "The --looponfail command line argument and looponfailroots config variable are deprecated.\n "
@@ -213,12 +226,6 @@ def pytest_configure(config):
213226 )
214227 config .issue_config_time_warning (warning , 2 )
215228
216- config_line = (
217- "xdist_group: specify group for tests should run in same session."
218- "in relation to one another. " + "Provided by pytest-xdist."
219- )
220- config .addinivalue_line ("markers" , config_line )
221-
222229
223230@pytest .hookimpl (tryfirst = True )
224231def pytest_cmdline_main (config ):
0 commit comments