Mercurial > genshi > genshi-test
comparison markup/tests/template.py @ 75:c3c26300a46d
Empty attributes in templates were being stripped out. Thanks to Jonas for the patch.
author | cmlenz |
---|---|
date | Wed, 12 Jul 2006 21:27:30 +0000 |
parents | 3c271699c398 |
children | f1aa49c759b2 |
comparison
equal
deleted
inserted
replaced
74:3c271699c398 | 75:c3c26300a46d |
---|---|
415 ctxt = Context(var=42) | 415 ctxt = Context(var=42) |
416 tmpl = Template('<root> ${var} $var</root>') | 416 tmpl = Template('<root> ${var} $var</root>') |
417 self.assertEqual('<root> 42 42</root>', str(tmpl.generate(ctxt))) | 417 self.assertEqual('<root> 42 42</root>', str(tmpl.generate(ctxt))) |
418 | 418 |
419 def test_interpolate_non_string_attrs(self): | 419 def test_interpolate_non_string_attrs(self): |
420 ctxt = Context() | |
421 tmpl = Template('<root attr="${1}"/>') | 420 tmpl = Template('<root attr="${1}"/>') |
422 self.assertEqual('<root attr="1"/>', str(tmpl.generate(ctxt))) | 421 self.assertEqual('<root attr="1"/>', str(tmpl.generate())) |
422 | |
423 def test_empty_attr(self): | |
424 tmpl = Template('<root attr=""/>') | |
425 self.assertEqual('<root attr=""/>', str(tmpl.generate())) | |
423 | 426 |
424 def test_bad_directive_error(self): | 427 def test_bad_directive_error(self): |
425 xml = '<p xmlns:py="http://markup.edgewall.org/" py:do="nothing" />' | 428 xml = '<p xmlns:py="http://markup.edgewall.org/" py:do="nothing" />' |
426 try: | 429 try: |
427 tmpl = Template(xml, filename='test.html') | 430 tmpl = Template(xml, filename='test.html') |
432 | 435 |
433 def test_directive_value_syntax_error(self): | 436 def test_directive_value_syntax_error(self): |
434 xml = '<p xmlns:py="http://markup.edgewall.org/" py:if="bar\'" />' | 437 xml = '<p xmlns:py="http://markup.edgewall.org/" py:if="bar\'" />' |
435 tmpl = Template(xml, filename='test.html') | 438 tmpl = Template(xml, filename='test.html') |
436 try: | 439 try: |
437 list(tmpl.generate(Context())) | 440 list(tmpl.generate()) |
438 self.fail('Expected SyntaxError') | 441 self.fail('Expected SyntaxError') |
439 except TemplateSyntaxError, e: | 442 except TemplateSyntaxError, e: |
440 self.assertEqual('test.html', e.filename) | 443 self.assertEqual('test.html', e.filename) |
441 if sys.version_info[:2] >= (2, 4): | 444 if sys.version_info[:2] >= (2, 4): |
442 self.assertEqual(1, e.lineno) | 445 self.assertEqual(1, e.lineno) |