Exemple #1
0
 def run_behavior_test(self, template_filename):
     base_filename = template_filename.rsplit('.', 1)[0]
     with open(base_filename + '.json') as f:
         context = json.load(f)
     with open(base_filename + '.output') as f:
         expected_output = f.read()
         if expected_output[-1] == '\n':
             expected_output = expected_output[:-1]
     output = self.evaluate_template(os.path.basename(template_filename),
                                     context)
     self.assert_equal(expected_output, output)
Exemple #2
0
 def run_behavior_test(self, template_filename):
     base_filename = template_filename.rsplit('.', 1)[0]
     with open(base_filename + '.json') as f:
         context = json.load(f)
     with open(base_filename + '.output') as f:
         expected_output = f.read()
         if expected_output[-1] == '\n':
             expected_output = expected_output[:-1]
     output = self.evaluate_template(os.path.basename(template_filename),
                                     context)
     self.assert_equal(expected_output, output)
Exemple #3
0
 def render(self, *args, **kwargs):
     if not args:
         context = {}
     elif len(args) == 1:
         context = args[0]
         if isinstance(context, basestring):
             context = json.loads(context)
         elif hasattr(context, 'read'):
             context = json.load(context)
         else:
             context = dict(context)
     if kwargs:
         context.update(kwargs)
     if __debug__:
         ensure_json_compatible(context)
     return u''.join(self.execute(context))