def test_create__precedence_keyword(self): """ Test precedence of keyword arguments. """ context = Context.create({'foo': 'bar'}, foo='buzz') self.assertEqual(context.get('foo'), 'buzz')
def test_create__kwarg(self): """ Test passing a keyword argument. """ context = Context.create(foo='bar') self.assertEqual(context.get('foo'), 'bar')
def test_create__precedence_positional(self): """ Test precedence of positional arguments. """ context = Context.create({'foo': 'bar'}, {'foo': 'buzz'}) self.assertEqual(context.get('foo'), 'buzz')
def test_create__dictionary(self): """ Test passing a dictionary. """ context = Context.create({'foo': 'bar'}) self.assertEqual(context.get('foo'), 'bar')
def test_create__none(self): """ Test passing None. """ context = Context.create({'foo': 'bar'}, None) self.assertEqual(context.get('foo'), 'bar')
def test_create__precedence_positional(self): """ Test precedence of positional arguments. """ context = Context.create({'foo': 'bar'}, {'foo': 'buzz'}) self.assertEquals(context.get('foo'), 'buzz')
def test_create__precedence_keyword(self): """ Test precedence of keyword arguments. """ context = Context.create({'foo': 'bar'}, foo='buzz') self.assertEquals(context.get('foo'), 'buzz')
def test_create__none(self): """ Test passing None. """ context = Context.create({'foo': 'bar'}, None) self.assertEquals(context.get('foo'), 'bar')
def test_create__kwarg(self): """ Test passing a keyword argument. """ context = Context.create(foo='bar') self.assertEquals(context.get('foo'), 'bar')
def test_create__dictionary(self): """ Test passing a dictionary. """ context = Context.create({'foo': 'bar'}) self.assertEquals(context.get('foo'), 'bar')
def test_create__context(self): """ Test passing a Context instance. """ obj = Context({'foo': 'bar'}) context = Context.create(obj) self.assertEqual(context.get('foo'), 'bar')
def test_create__context(self): """ Test passing a Context instance. """ obj = Context({'foo': 'bar'}) context = Context.create(obj) self.assertEquals(context.get('foo'), 'bar')
def test_create__object(self): """ Test passing an object. """ class Foo(object): foo = 'bar' context = Context.create(Foo()) self.assertEqual(context.get('foo'), 'bar')
def test_create__object(self): """ Test passing an object. """ class Foo(object): foo = 'bar' context = Context.create(Foo()) self.assertEquals(context.get('foo'), 'bar')
def _render_string(self, template, *context, **kwargs): """ Render the given template string using the given context. """ # RenderEngine.render() requires that the template string be unicode. template = self._to_unicode_hard(template) context = Context.create(*context, **kwargs) self._context = context engine = self._make_render_engine() rendered = engine.render(template, context) return unicode(rendered)
def _render_string(self, template, *context, **kwargs): """ Render the given template string using the given context. """ # RenderEngine.render() requires that the template string be unicode. template = self._to_unicode_hard(template) context = Context.create(*context, **kwargs) self._context = context engine = self._make_render_engine() rendered = engine.render(template, context) return str(rendered)