Mercurial > genshi > mirror
annotate markup/tests/builder.py @ 148:dcc9dc25bc59 trunk
Added changelog file, plus some README and setup tweaks.
author | cmlenz |
---|---|
date | Tue, 15 Aug 2006 14:41:08 +0000 |
parents | 44af12832c5a |
children |
rev | line source |
---|---|
1 | 1 # -*- coding: utf-8 -*- |
2 # | |
66
59eb24184e9c
Switch copyright to Edgewall and URLs to markup.edgewall.org.
cmlenz
parents:
27
diff
changeset
|
3 # Copyright (C) 2006 Edgewall Software |
1 | 4 # All rights reserved. |
5 # | |
6 # This software is licensed as described in the file COPYING, which | |
7 # you should have received as part of this distribution. The terms | |
66
59eb24184e9c
Switch copyright to Edgewall and URLs to markup.edgewall.org.
cmlenz
parents:
27
diff
changeset
|
8 # are also available at http://markup.edgewall.org/wiki/License. |
1 | 9 # |
10 # This software consists of voluntary contributions made by many | |
11 # individuals. For the exact contribution history, see the revision | |
66
59eb24184e9c
Switch copyright to Edgewall and URLs to markup.edgewall.org.
cmlenz
parents:
27
diff
changeset
|
12 # history and logs, available at http://markup.edgewall.org/log/. |
1 | 13 |
14 import doctest | |
15 from HTMLParser import HTMLParseError | |
16 import unittest | |
17 | |
18 from markup.builder import Element, tag | |
19 from markup.core import Stream | |
20 | |
21 | |
22 class ElementFactoryTestCase(unittest.TestCase): | |
23 | |
24 def test_link(self): | |
20 | 25 link = tag.a(href='#', title='Foo', accesskey=None)('Bar') |
1 | 26 bits = iter(link.generate()) |
27 self.assertEqual((Stream.START, ('a', [('href', "#"), ('title', "Foo")]), | |
94
0f8800c46e21
Some bugfixes and minor performance improvements for the builder module.
cmlenz
parents:
66
diff
changeset
|
28 (None, -1, -1)), bits.next()) |
0f8800c46e21
Some bugfixes and minor performance improvements for the builder module.
cmlenz
parents:
66
diff
changeset
|
29 self.assertEqual((Stream.TEXT, u'Bar', (None, -1, -1)), bits.next()) |
0f8800c46e21
Some bugfixes and minor performance improvements for the builder module.
cmlenz
parents:
66
diff
changeset
|
30 self.assertEqual((Stream.END, 'a', (None, -1, -1)), bits.next()) |
1 | 31 |
98
44af12832c5a
Bugfix in `builder` module: attribute values need to be converted to strings when generating streams.
cmlenz
parents:
94
diff
changeset
|
32 def test_nonstring_attributes(self): |
44af12832c5a
Bugfix in `builder` module: attribute values need to be converted to strings when generating streams.
cmlenz
parents:
94
diff
changeset
|
33 """ |
44af12832c5a
Bugfix in `builder` module: attribute values need to be converted to strings when generating streams.
cmlenz
parents:
94
diff
changeset
|
34 Verify that if an attribute value is given as an int (or some other |
44af12832c5a
Bugfix in `builder` module: attribute values need to be converted to strings when generating streams.
cmlenz
parents:
94
diff
changeset
|
35 non-string type), it is coverted to a string when the stream is |
44af12832c5a
Bugfix in `builder` module: attribute values need to be converted to strings when generating streams.
cmlenz
parents:
94
diff
changeset
|
36 generated. |
44af12832c5a
Bugfix in `builder` module: attribute values need to be converted to strings when generating streams.
cmlenz
parents:
94
diff
changeset
|
37 """ |
44af12832c5a
Bugfix in `builder` module: attribute values need to be converted to strings when generating streams.
cmlenz
parents:
94
diff
changeset
|
38 event = iter(tag.foo(id=3)).next() |
44af12832c5a
Bugfix in `builder` module: attribute values need to be converted to strings when generating streams.
cmlenz
parents:
94
diff
changeset
|
39 self.assertEqual((Stream.START, ('foo', [('id', '3')]), (None, -1, -1)), |
44af12832c5a
Bugfix in `builder` module: attribute values need to be converted to strings when generating streams.
cmlenz
parents:
94
diff
changeset
|
40 event) |
44af12832c5a
Bugfix in `builder` module: attribute values need to be converted to strings when generating streams.
cmlenz
parents:
94
diff
changeset
|
41 |
1 | 42 |
43 def suite(): | |
44 suite = unittest.TestSuite() | |
45 suite.addTest(doctest.DocTestSuite(Element.__module__)) | |
46 suite.addTest(unittest.makeSuite(ElementFactoryTestCase, 'test')) | |
47 return suite | |
48 | |
49 if __name__ == '__main__': | |
50 unittest.main(defaultTest='suite') |