Merge pull request #4015 from dnephin/fix-inline-defaults

Support non-alphanumeric default values.
This commit is contained in:
Joffrey F 2016-10-06 15:46:35 -07:00 committed by GitHub
commit 804555bc4d
2 changed files with 2 additions and 1 deletions

View File

@ -72,7 +72,7 @@ def recursive_interpolate(obj, interpolator):
class TemplateWithDefaults(Template):
idpattern = r'[_a-z][_a-z0-9]*(?::?-[_a-z0-9]+)?'
idpattern = r'[_a-z][_a-z0-9]*(?::?-[^}]+)?'
# Modified from python2.7/string.py
def substitute(self, mapping):

View File

@ -113,6 +113,7 @@ def test_interpolate_with_value(defaults_interpolator):
def test_interpolate_missing_with_default(defaults_interpolator):
assert defaults_interpolator("ok ${missing:-def}") == "ok def"
assert defaults_interpolator("ok ${missing-def}") == "ok def"
assert defaults_interpolator("ok ${BAR:-/non:-alphanumeric}") == "ok /non:-alphanumeric"
def test_interpolate_with_empty_and_default_value(defaults_interpolator):