@@ -590,6 +590,29 @@ def test_config_precedence():
590590 assert cfg (f = LOCAL )['pytest' ]['precedence' ] == 'local'
591591
592592
593+ TEST_CASES_CONFIG_RELATIVE = [
594+ # (flag, env_var)
595+ ('--local' , 'WEST_CONFIG_LOCAL' ),
596+ ('--system' , 'WEST_CONFIG_SYSTEM' ),
597+ ('--global' , 'WEST_CONFIG_GLOBAL' ),
598+ ]
599+
600+
601+ @pytest .mark .parametrize ("test_case" , TEST_CASES_CONFIG_RELATIVE )
602+ def test_config_relative_paths (test_case , config_tmpdir ):
603+ flag , env_var = test_case
604+
605+ # one relative config file path is specified
606+ os .environ [env_var ] = 'config1'
607+ stderr = cmd_raises (f'config { flag } some.key' , subprocess .CalledProcessError )
608+ assert f"config file path(s) must be absolute: '{ os .environ [env_var ]} '" in stderr
609+
610+ # one of multiple config file paths is relative
611+ os .environ [env_var ] = f'config1{ os .pathsep } config2'
612+ stderr = cmd_raises (f'config { flag } some.key' , subprocess .CalledProcessError )
613+ assert f"config file path(s) must be absolute: '{ os .environ [env_var ]} '" in stderr
614+
615+
593616def test_config_multiple (config_tmpdir ):
594617 # Verify that local settings take precedence over global ones,
595618 # but that both values are still available, and that setting
0 commit comments