def latter_description(): latter = { "Name": "Konstantin", "Later": "Hello {Name},\n" "I'm a test latter for you.\n\n" "Kind Regards,\n" "{Name}\n" } print substitute(latter, latter)['Later']
def test_sub_self_dict(): d = {'a': '{b}', 'b': 'c'} eq_( substitute(d, d), {'a': 'c', 'b': 'c'}, "Self substitution" )
def test_sub_two_inner_dict(): eq_( substitute({'a': {'a': "{a}"}}, {'a': 't'}), {'a': {'a': "t"}}, "Inner dict handled" )
def test_sub_several_in_one_val(): eq_( substitute({'a': "{h}+{h}+{a}"}, {'a': 't', 'h': "d"}), {'a': "d+d+t"}, "Several substitution in one value" )
def test_sub_simple_dict(): eq_( substitute({'a': "{h}"}, {'h': "d"}), {'a': "d"}, "Simple string substitution" )
def test_sub_empty_dict(): eq_( substitute({'a': "{h}"}, {}), {'a': "{h}"}, "Substitute empty dict doesn't change anything" )