def test_interpolate_unicode_values(): variable_mapping = { 'FOO': '十六夜 咲夜'.encode('utf-8'), 'BAR': '十六夜 咲夜' } interpol = Interpolator(TemplateWithDefaults, variable_mapping).interpolate interpol("$FOO") == '十六夜 咲夜' interpol("${BAR}") == '十六夜 咲夜'
def test_interpolate_no_fallthrough(): # Test regression on docker/compose#5829 variable_mapping = { 'TEST:-': 'hello', 'TEST-': 'hello', } interpol = Interpolator(TemplateWithDefaults, variable_mapping).interpolate assert interpol('${TEST:-}') == '' assert interpol('${TEST-}') == ''
def defaults_interpolator(variable_mapping): return Interpolator(TemplateWithDefaults, variable_mapping).interpolate