cmlenz@1: # -*- coding: utf-8 -*- cmlenz@1: # cmlenz@1: # Copyright (C) 2006 Christopher Lenz cmlenz@1: # All rights reserved. cmlenz@1: # cmlenz@1: # This software is licensed as described in the file COPYING, which cmlenz@1: # you should have received as part of this distribution. The terms cmlenz@27: # are also available at http://markup.cmlenz.net/wiki/License. cmlenz@1: # cmlenz@1: # This software consists of voluntary contributions made by many cmlenz@1: # individuals. For the exact contribution history, see the revision cmlenz@27: # history and logs, available at http://markup.cmlenz.net/log/. cmlenz@1: cmlenz@1: import doctest cmlenz@1: from HTMLParser import HTMLParseError cmlenz@1: import unittest cmlenz@1: cmlenz@1: from markup.builder import Element, tag cmlenz@1: from markup.core import Stream cmlenz@1: cmlenz@1: cmlenz@1: class ElementFactoryTestCase(unittest.TestCase): cmlenz@1: cmlenz@1: def test_link(self): cmlenz@20: link = tag.a(href='#', title='Foo', accesskey=None)('Bar') cmlenz@1: bits = iter(link.generate()) cmlenz@1: self.assertEqual((Stream.START, ('a', [('href', "#"), ('title', "Foo")]), cmlenz@1: (-1, -1)), bits.next()) cmlenz@1: self.assertEqual((Stream.TEXT, u'Bar', (-1, -1)), bits.next()) cmlenz@1: self.assertEqual((Stream.END, 'a', (-1, -1)), bits.next()) cmlenz@1: cmlenz@1: cmlenz@1: def suite(): cmlenz@1: suite = unittest.TestSuite() cmlenz@1: suite.addTest(doctest.DocTestSuite(Element.__module__)) cmlenz@1: suite.addTest(unittest.makeSuite(ElementFactoryTestCase, 'test')) cmlenz@1: return suite cmlenz@1: cmlenz@1: if __name__ == '__main__': cmlenz@1: unittest.main(defaultTest='suite')