summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tox/config.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/tox/config.py b/tox/config.py
index d68d276..17fdccf 100644
--- a/tox/config.py
+++ b/tox/config.py
@@ -903,6 +903,7 @@ class SectionReader:
return '\n'.join(filter(None, map(factor_line, lines)))
def _replace_env(self, match):
+ env_list = self._build_envs_list()
match_value = match.group('substitution_value')
if not match_value:
raise tox.exception.ConfigError(
@@ -917,11 +918,21 @@ class SectionReader:
envkey = match_value
if envkey not in os.environ and default is None:
- raise tox.exception.ConfigError(
- "substitution env:%r: unknown environment variable %r" %
- (envkey, envkey))
+ if envkey not in env_list and default is None:
+ raise tox.exception.ConfigError(
+ "substitution env:%r: unknown environment variable %r" %
+ (envkey, envkey))
+ if envkey in os.environ:
+ return os.environ.get(envkey, default)
+ else:
+ return env_list.get(envkey, default)
- return os.environ.get(envkey, default)
+ def _build_envs_list(self):
+ full_envs = self._cfg[self.section_name].get('setenv')
+ if full_envs:
+ return {k.split('=')[0]: k.split('=')[1] for k in full_envs.split('\n')}
+ else:
+ return {}
def _substitute_from_other_section(self, key):
if key.startswith("[") and "]" in key: