@@ -139,7 +139,7 @@ def test_config_list_paths_extended():
139139 { WEST_CONFIG_LOCAL }
140140 ''' ).splitlines ()
141141
142- # create some dropins files
142+ # create some dropin config files
143143 dropin_files = [
144144 pathlib .Path (WEST_CONFIG_GLOBAL + '.d' ) / 'a.conf' ,
145145 pathlib .Path (WEST_CONFIG_GLOBAL + '.d' ) / 'z.conf' ,
@@ -283,24 +283,25 @@ def test_local_creation():
283283 assert 'pytest' not in cfg (f = GLOBAL )
284284 assert cfg (f = LOCAL )['pytest' ]['key' ] == 'val'
285285
286- TEST_CASES_CONFIG_D = [
286+ TEST_CASES_DROPIN_CONFIGS = [
287287 # (flag, env_var)
288288 ('' , 'WEST_CONFIG_LOCAL' ),
289289 ('--local' , 'WEST_CONFIG_LOCAL' ),
290290 ('--system' , 'WEST_CONFIG_SYSTEM' ),
291291 ('--global' , 'WEST_CONFIG_GLOBAL' ),
292292]
293293
294- @pytest .mark .parametrize ("test_case" , TEST_CASES_CONFIG_D )
295- def test_config_d_local (test_case ):
294+ @pytest .mark .parametrize ("test_case" , TEST_CASES_DROPIN_CONFIGS )
295+ def test_config_dropins (test_case ):
296296 flag , env_var = test_case
297297 config_path = pathlib .Path (os .environ [env_var ])
298- config_d_dir = pathlib .Path (f'{ config_path } .d' )
299- config_d_dir .mkdir ()
298+ dropin_configs_dir = pathlib .Path (f'{ config_path } .d' )
299+ dropin_configs_dir .mkdir ()
300300
301301 # write value in actual config file
302302 cmd (f'config { flag } pytest.key val' )
303303 cmd (f'config { flag } pytest.config-only val' )
304+ cmd (f'config { flag } config.dropins true' )
304305
305306 # read config value via command line
306307 stdout = cmd (f'config { flag } pytest.key' )
@@ -316,10 +317,13 @@ def test_config_d_local(test_case):
316317 key = val
317318 config-only = val
318319
320+ [config]
321+ dropins = true
322+
319323 ''' )
320324
321325 # create a dropin config under .d
322- with open (config_d_dir / 'a.conf' , 'w' ) as conf :
326+ with open (dropin_configs_dir / 'a.conf' , 'w' ) as conf :
323327 conf .write (textwrap .dedent ('''
324328 [pytest]
325329 key = from dropin a
@@ -328,7 +332,7 @@ def test_config_d_local(test_case):
328332 ''' ))
329333
330334 # create a dropin config under .d
331- with open (config_d_dir / 'z.conf' , 'w' ) as conf :
335+ with open (dropin_configs_dir / 'z.conf' , 'w' ) as conf :
332336 conf .write (textwrap .dedent ('''
333337 [pytest]
334338 dropin-only = from dropin z
@@ -358,16 +362,20 @@ def test_config_d_local(test_case):
358362 [pytest]
359363 key = val
360364
365+ [config]
366+ dropins = true
367+
361368 ''' )
362369
363- # remove config file
370+ # remove config file and only set config.dropins true again
364371 config_path .unlink ()
372+ cmd (f'config { flag } config.dropins true' )
365373
366374 # values from config are unset now
367375 stderr = cmd_raises (f'config { flag } pytest.config-only' , subprocess .CalledProcessError )
368376 assert 'ERROR: pytest.config-only is unset' == stderr .rstrip ()
369377
370- # dropin applies now, since config does not exist
378+ # dropin config values are used now, since they are not set in config
371379 stdout = cmd (f'config { flag } pytest.key' )
372380 assert 'from dropin a' == stdout .rstrip ()
373381 # alphabetical order (z.conf is overwriting a.conf)
@@ -383,6 +391,14 @@ def test_config_d_local(test_case):
383391 # deletion of a value that is not existing anymore should fail
384392 cmd_raises (f'config { flag } -d pytest.config-only' , subprocess .CalledProcessError )
385393
394+ # remove config (config.dropins is false by default)
395+ config_path .unlink ()
396+
397+ # values from dropin configs are not considered now
398+ cmd_raises (f'config { flag } pytest.key' , subprocess .CalledProcessError )
399+ cmd_raises (f'config { flag } pytest.dropin-only' , subprocess .CalledProcessError )
400+ cmd_raises (f'config { flag } pytest.dropin-only-a' , subprocess .CalledProcessError )
401+ cmd_raises (f'config { flag } pytest.dropin-only-z' , subprocess .CalledProcessError )
386402
387403def test_local_creation_with_topdir ():
388404 # Like test_local_creation, with a specified topdir.
0 commit comments