Permalink
Browse files

fix issue with objects as values and some unicode characters

  • Loading branch information...
1 parent 5d1b59c commit ea0d2058d9ccfbeafc2e457c6a4bdc8d68eee67e @erasmospunk erasmospunk committed Nov 11, 2013
Showing with 11 additions and 1 deletion.
  1. +1 −1 airspeed/__init__.py
  2. +10 −0 tests/airspeed_test.py
View
@@ -553,7 +553,7 @@ def evaluate(self, stream, namespace, loader):
if is_string(value):
stream.write(value)
else:
- stream.write(str(value))
+ stream.write(unicode(value))
class Null:
View
@@ -685,6 +685,16 @@ def test_preserves_unicode_strings(self):
value = unicode('Grüße', 'latin1')
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):
class Loader:
def load_template(self, name):

0 comments on commit ea0d205

Please sign in to comment.