@@ -1829,8 +1829,9 @@ def _replace_match(self, match):
1829
1829
1830
1830
return os .pathsep
1831
1831
1832
+ default_value = g ["default_value" ]
1832
1833
if sub_value == "posargs" :
1833
- return self .reader .getposargs (match . group ( " default_value" ) )
1834
+ return self .reader .getposargs (default_value )
1834
1835
1835
1836
sub_type = g ["sub_type" ]
1836
1837
if not sub_type and not sub_value :
@@ -1839,27 +1840,26 @@ def _replace_match(self, match):
1839
1840
"If you were using `{}` for `os.pathsep`, please use `{:}`." ,
1840
1841
)
1841
1842
1842
- if not sub_type and not g [ " default_value" ] and sub_value == "/" :
1843
+ if not sub_type and not default_value and sub_value == "/" :
1843
1844
return os .sep
1845
+
1844
1846
if sub_type == "env" :
1845
- return self ._replace_env (match )
1847
+ return self ._replace_env (sub_value , default_value )
1846
1848
if sub_type == "tty" :
1847
1849
if is_interactive ():
1848
1850
return match .group ("substitution_value" )
1849
1851
return match .group ("default_value" )
1850
1852
if sub_type == "posargs" :
1851
- return self .reader .getposargs (match . group ( "substitution_value" ) )
1853
+ return self .reader .getposargs (sub_value )
1852
1854
if sub_type is not None :
1853
1855
raise tox .exception .ConfigError (
1854
1856
"No support for the {} substitution type" .format (sub_type ),
1855
1857
)
1856
- return self ._replace_substitution (match )
1858
+ return self ._replace_substitution (sub_value )
1857
1859
1858
- def _replace_env (self , match ):
1859
- key = match .group ("substitution_value" )
1860
+ def _replace_env (self , key , default ):
1860
1861
if not key :
1861
1862
raise tox .exception .ConfigError ("env: requires an environment variable name" )
1862
- default = match .group ("default_value" )
1863
1863
value = self .reader .get_environ_value (key )
1864
1864
if value is not None :
1865
1865
return value
@@ -1887,8 +1887,7 @@ def _substitute_from_other_section(self, key):
1887
1887
1888
1888
raise tox .exception .ConfigError ("substitution key {!r} not found" .format (key ))
1889
1889
1890
- def _replace_substitution (self , match ):
1891
- sub_key = match .group ("substitution_value" )
1890
+ def _replace_substitution (self , sub_key ):
1892
1891
val = self .reader ._subs .get (sub_key , None )
1893
1892
if val is None :
1894
1893
val = self ._substitute_from_other_section (sub_key )
0 commit comments