Skip to content

Commit

Permalink
Don't attempt to parse dicts if not replacing
Browse files Browse the repository at this point in the history
When reading in the config and processing dict content we were splitting
on = assuming we would always have key = value pairs. However in the
case where we don't want to replace because the testenv will not be used
this can result in ValueErrors as substitution variables are not string
key = value pairs.

Avoid all this by only attempting to process dict key = values if we are
replacing in the first place. Otherwise the content isn't needed and we
just return the default value or empty dict.

This should fix tox-dev#595
  • Loading branch information
cboylan committed Sep 1, 2017
1 parent a766e06 commit 495d139
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,16 +957,17 @@ def getlist(self, name, sep="\n"):

def getdict(self, name, default=None, sep="\n", replace=True):
value = self.getstring(name, None, replace=replace)
return self._getdict(value, default=default, sep=sep)
return self._getdict(value, default=default, sep=sep, replace=replace)

def getdict_setenv(self, name, default=None, sep="\n", replace=True):
value = self.getstring(name, None, replace=replace, crossonly=True)
definitions = self._getdict(value, default=default, sep=sep)
definitions = self._getdict(value, default=default, sep=sep,
replace=replace)
self._setenv = SetenvDict(definitions, reader=self)
return self._setenv

def _getdict(self, value, default, sep):
if value is None:
def _getdict(self, value, default, sep, replace=True):
if value is None or not replace:
return default or {}

d = {}
Expand Down

0 comments on commit 495d139

Please sign in to comment.