Changeset 13 for trunk/airspeed_test.py

Show
Ignore:
Timestamp:
13/08/04 14:00:26 (8 years ago)
Author:
steve
Message:

Template.merge_to(namespace, fileobj)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/airspeed_test.py

    r12 r13  
    2525    def test_silent_substitution_for_unmatched_values(self): 
    2626        template = airspeed.Template("Hello $!name") 
     27        self.assertEquals("Hello world", template.merge({"name": "world"})) 
    2728        self.assertEquals("Hello ", template.merge({})) 
    28         self.assertEquals("Hello world", template.merge({"name": "world"})) 
    2929 
    3030    def test_embed_substitution_value_in_braces_gets_handled(self): 
     
    139139        self.assertEquals("Stuff and more stuff", template.merge({})) 
    140140 
     141    def test_merge_to_stream(self): 
     142        template = airspeed.Template('Hello $name!') 
     143        from cStringIO import StringIO 
     144        output = StringIO() 
     145        template.merge_to({"name": "Chris"}, output) 
     146        self.assertEquals('Hello Chris!', output.getvalue()) 
     147 
     148#    def test_else_block_evaluated_if_if_expression_false(self): 
     149#        template = airspeed.Template('#if ($value) true #else false #end') 
     150#        self.assertEquals(" false ", template.merge({})) 
     151 
     152 
     153# 
     154# TODO: 
     155# 
     156#  Escaped characters in string literals 
     157#  Directives inside string literals 
     158#  #else, #elseif 
     159#  Parameterised calls 
     160#  #parse, #include 
     161#  #macro 
     162#  map literals 
     163#  Escaped $, # 
     164#  Sub-object assignment:  #set( $customer.Behavior = $primate ) 
     165# 
     166 
     167 
    141168if __name__ == '__main__': 
    142169    reload(airspeed)