Skip to content

Commit

Permalink
fix issue with objects as values and some unicode characters
Browse files Browse the repository at this point in the history
  • Loading branch information
erasmospunk committed Nov 11, 2013
1 parent 5d1b59c commit ea0d205
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion airspeed/__init__.py
Expand Up @@ -553,7 +553,7 @@ def evaluate(self, stream, namespace, loader):
if is_string(value): if is_string(value):
stream.write(value) stream.write(value)
else: else:
stream.write(str(value)) stream.write(unicode(value))




class Null: class Null:
Expand Down
10 changes: 10 additions & 0 deletions tests/airspeed_test.py
Expand Up @@ -685,6 +685,16 @@ def test_preserves_unicode_strings(self):
value = unicode('Grüße', 'latin1') value = unicode('Grüße', 'latin1')
self.assertEquals(value, template.merge(locals())) self.assertEquals(value, template.merge(locals()))


def test_preserves_unicode_strings_objects(self):
template = airspeed.Template('$value')
class Clazz:
def __init__(self, value):
self.value = value
def __str__(self):
return self.value
value = Clazz(u'£12,000')
self.assertEquals(unicode(value), template.merge(locals()))

def test_can_define_macros_in_parsed_files(self): def test_can_define_macros_in_parsed_files(self):
class Loader: class Loader:
def load_template(self, name): def load_template(self, name):
Expand Down

0 comments on commit ea0d205

Please sign in to comment.