@@ -792,7 +792,8 @@ def __init__(self, config, inipath):
792
792
factors = set (name .split ('-' ))
793
793
if section in self ._cfg or factors <= known_factors :
794
794
config .envconfigs [name ] = \
795
- self .make_envconfig (name , section , reader ._subs , config )
795
+ self .make_envconfig (name , section , reader ._subs , config ,
796
+ replace = name in config .envlist )
796
797
797
798
all_develop = all (name in config .envconfigs
798
799
and config .envconfigs [name ].usedevelop
@@ -808,7 +809,7 @@ def _list_section_factors(self, section):
808
809
factors .update (* mapcat (_split_factor_expr , exprs ))
809
810
return factors
810
811
811
- def make_envconfig (self , name , section , subs , config ):
812
+ def make_envconfig (self , name , section , subs , config , replace = True ):
812
813
factors = set (name .split ('-' ))
813
814
reader = SectionReader (section , self ._cfg , fallbacksections = ["testenv" ],
814
815
factors = factors )
@@ -823,7 +824,7 @@ def make_envconfig(self, name, section, subs, config):
823
824
atype = env_attr .type
824
825
if atype in ("bool" , "path" , "string" , "dict" , "dict_setenv" , "argv" , "argvlist" ):
825
826
meth = getattr (reader , "get" + atype )
826
- res = meth (env_attr .name , env_attr .default )
827
+ res = meth (env_attr .name , env_attr .default , replace = replace )
827
828
elif atype == "space-separated-list" :
828
829
res = reader .getlist (env_attr .name , sep = " " )
829
830
elif atype == "line-list" :
@@ -942,9 +943,9 @@ def addsubstitutions(self, _posargs=None, **kw):
942
943
if _posargs :
943
944
self .posargs = _posargs
944
945
945
- def getpath (self , name , defaultpath ):
946
+ def getpath (self , name , defaultpath , replace = True ):
946
947
toxinidir = self ._subs ['toxinidir' ]
947
- path = self .getstring (name , defaultpath )
948
+ path = self .getstring (name , defaultpath , replace = replace )
948
949
if path is not None :
949
950
return toxinidir .join (path , abs = True )
950
951
@@ -954,12 +955,12 @@ def getlist(self, name, sep="\n"):
954
955
return []
955
956
return [x .strip () for x in s .split (sep ) if x .strip ()]
956
957
957
- def getdict (self , name , default = None , sep = "\n " ):
958
+ def getdict (self , name , default = None , sep = "\n " , replace = True ):
958
959
value = self .getstring (name , None )
959
960
return self ._getdict (value , default = default , sep = sep )
960
961
961
- def getdict_setenv (self , name , default = None , sep = "\n " ):
962
- value = self .getstring (name , None , replace = True , crossonly = True )
962
+ def getdict_setenv (self , name , default = None , sep = "\n " , replace = True ):
963
+ value = self .getstring (name , None , replace = replace , crossonly = True )
963
964
definitions = self ._getdict (value , default = default , sep = sep )
964
965
self ._setenv = SetenvDict (definitions , reader = self )
965
966
return self ._setenv
@@ -976,8 +977,8 @@ def _getdict(self, value, default, sep):
976
977
977
978
return d
978
979
979
- def getbool (self , name , default = None ):
980
- s = self .getstring (name , default )
980
+ def getbool (self , name , default = None , replace = True ):
981
+ s = self .getstring (name , default , replace = replace )
981
982
if not s :
982
983
s = default
983
984
if s is None :
@@ -994,12 +995,12 @@ def getbool(self, name, default=None):
994
995
"boolean value %r needs to be 'True' or 'False'" )
995
996
return s
996
997
997
- def getargvlist (self , name , default = "" ):
998
+ def getargvlist (self , name , default = "" , replace = True ):
998
999
s = self .getstring (name , default , replace = False )
999
- return _ArgvlistReader .getargvlist (self , s )
1000
+ return _ArgvlistReader .getargvlist (self , s , replace = replace )
1000
1001
1001
- def getargv (self , name , default = "" ):
1002
- return self .getargvlist (name , default )[0 ]
1002
+ def getargv (self , name , default = "" , replace = True ):
1003
+ return self .getargvlist (name , default , replace = replace )[0 ]
1003
1004
1004
1005
def getstring (self , name , default = None , replace = True , crossonly = False ):
1005
1006
x = None
@@ -1153,7 +1154,7 @@ def _replace_substitution(self, match):
1153
1154
1154
1155
class _ArgvlistReader :
1155
1156
@classmethod
1156
- def getargvlist (cls , reader , value ):
1157
+ def getargvlist (cls , reader , value , replace = True ):
1157
1158
"""Parse ``commands`` argvlist multiline string.
1158
1159
1159
1160
:param str name: Key name in a section.
@@ -1178,7 +1179,7 @@ def getargvlist(cls, reader, value):
1178
1179
replaced = reader ._replace (current_command , crossonly = True )
1179
1180
commands .extend (cls .getargvlist (reader , replaced ))
1180
1181
else :
1181
- commands .append (cls .processcommand (reader , current_command ))
1182
+ commands .append (cls .processcommand (reader , current_command , replace ))
1182
1183
current_command = ""
1183
1184
else :
1184
1185
if current_command :
@@ -1188,31 +1189,34 @@ def getargvlist(cls, reader, value):
1188
1189
return commands
1189
1190
1190
1191
@classmethod
1191
- def processcommand (cls , reader , command ):
1192
+ def processcommand (cls , reader , command , replace = True ):
1192
1193
posargs = getattr (reader , "posargs" , "" )
1193
1194
posargs_string = list2cmdline ([x for x in posargs if x ])
1194
1195
1195
1196
# Iterate through each word of the command substituting as
1196
1197
# appropriate to construct the new command string. This
1197
1198
# string is then broken up into exec argv components using
1198
1199
# shlex.
1199
- newcommand = ""
1200
- for word in CommandParser (command ).words ():
1201
- if word == "{posargs}" or word == "[]" :
1202
- newcommand += posargs_string
1203
- continue
1204
- elif word .startswith ("{posargs:" ) and word .endswith ("}" ):
1205
- if posargs :
1200
+ if replace :
1201
+ newcommand = ""
1202
+ for word in CommandParser (command ).words ():
1203
+ if word == "{posargs}" or word == "[]" :
1206
1204
newcommand += posargs_string
1207
1205
continue
1208
- else :
1209
- word = word [9 :- 1 ]
1210
- new_arg = ""
1211
- new_word = reader ._replace (word )
1212
- new_word = reader ._replace (new_word )
1213
- new_word = new_word .replace ('\\ {' , '{' ).replace ('\\ }' , '}' )
1214
- new_arg += new_word
1215
- newcommand += new_arg
1206
+ elif word .startswith ("{posargs:" ) and word .endswith ("}" ):
1207
+ if posargs :
1208
+ newcommand += posargs_string
1209
+ continue
1210
+ else :
1211
+ word = word [9 :- 1 ]
1212
+ new_arg = ""
1213
+ new_word = reader ._replace (word )
1214
+ new_word = reader ._replace (new_word )
1215
+ new_word = new_word .replace ('\\ {' , '{' ).replace ('\\ }' , '}' )
1216
+ new_arg += new_word
1217
+ newcommand += new_arg
1218
+ else :
1219
+ newcommand = command
1216
1220
1217
1221
# Construct shlex object that will not escape any values,
1218
1222
# use all values as is in argv.
0 commit comments