Skip to content

Commit eedba99

Browse files
thorsten-kleinpdgendt
authored andcommitted
add 'west_env' and 'west_flag' dictionaries in tests
Dictionaries 'west_env' and 'west_flag' are added to test_config.py to simplify parameterized tests by iterating over the locations '[LOCAL, GLOBAL, SYSTEM]'.
1 parent a7838dc commit eedba99

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

tests/test_config.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919
LOCAL = config.ConfigFile.LOCAL
2020
ALL = config.ConfigFile.ALL
2121

22+
west_env = {
23+
SYSTEM: 'WEST_CONFIG_SYSTEM',
24+
GLOBAL: 'WEST_CONFIG_GLOBAL',
25+
LOCAL: 'WEST_CONFIG_LOCAL',
26+
}
27+
28+
west_flag = {
29+
SYSTEM: '--system',
30+
GLOBAL: '--global',
31+
LOCAL: '--local',
32+
}
33+
2234

2335
@pytest.fixture(autouse=True)
2436
def autouse_config_tmpdir(config_tmpdir):
@@ -93,18 +105,11 @@ def test_config_global():
93105
assert 'pytest' not in lcl
94106

95107

96-
TEST_CASES_CONFIG_LIST_PATHS = [
97-
# (flag, env_var)
98-
('--local', 'WEST_CONFIG_LOCAL'),
99-
('--system', 'WEST_CONFIG_SYSTEM'),
100-
('--global', 'WEST_CONFIG_GLOBAL'),
101-
]
102-
103-
104-
@pytest.mark.parametrize("test_case", TEST_CASES_CONFIG_LIST_PATHS)
105-
def test_config_list_paths_env(test_case):
108+
@pytest.mark.parametrize("location", [LOCAL, GLOBAL, SYSTEM])
109+
def test_config_list_paths_env(location):
106110
'''Test that --list-paths considers the env variables'''
107-
flag, env_var = test_case
111+
flag = west_flag[location]
112+
env_var = west_env[location]
108113

109114
# create the config
110115
cmd(f'config {flag} pytest.key val')

0 commit comments

Comments
 (0)