Mercurial > genshi > genshi-test
annotate genshi/filters/tests/html.py @ 708:49ae50aad908
Fix Python 2.3 compatibility of HTMLSanitizer unit tests.
author | cmlenz |
---|---|
date | Sun, 06 Apr 2008 20:39:48 +0000 |
parents | 84137a71a4ca |
children | 09a90feb9269 |
rev | line source |
---|---|
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
2 # |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
3 # Copyright (C) 2006 Edgewall Software |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
4 # All rights reserved. |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
5 # |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
6 # This software is licensed as described in the file COPYING, which |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
7 # you should have received as part of this distribution. The terms |
230 | 8 # are also available at http://genshi.edgewall.org/wiki/License. |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
9 # |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
10 # This software consists of voluntary contributions made by many |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
11 # individuals. For the exact contribution history, see the revision |
230 | 12 # history and logs, available at http://genshi.edgewall.org/log/. |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
13 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
14 import doctest |
708
49ae50aad908
Fix Python 2.3 compatibility of HTMLSanitizer unit tests.
cmlenz
parents:
584
diff
changeset
|
15 try: |
49ae50aad908
Fix Python 2.3 compatibility of HTMLSanitizer unit tests.
cmlenz
parents:
584
diff
changeset
|
16 set |
49ae50aad908
Fix Python 2.3 compatibility of HTMLSanitizer unit tests.
cmlenz
parents:
584
diff
changeset
|
17 except NameError: |
49ae50aad908
Fix Python 2.3 compatibility of HTMLSanitizer unit tests.
cmlenz
parents:
584
diff
changeset
|
18 from sets import Set as set |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
19 import unittest |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
20 |
230 | 21 from genshi.input import HTML, ParseError |
446
90f5908cd10a
Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
431
diff
changeset
|
22 from genshi.filters.html import HTMLFormFiller, HTMLSanitizer |
584
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
23 from genshi.template import MarkupTemplate |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
24 |
275
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
25 class HTMLFormFillerTestCase(unittest.TestCase): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
26 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
27 def test_fill_input_text_no_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
28 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
29 <input type="text" name="foo" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
30 </p></form>""") | HTMLFormFiller() |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
31 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
32 <input type="text" name="foo"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
33 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
34 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
35 def test_fill_input_text_single_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
36 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
37 <input type="text" name="foo" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
38 </p></form>""") | HTMLFormFiller(data={'foo': 'bar'}) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
39 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
40 <input type="text" name="foo" value="bar"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
41 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
42 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
43 def test_fill_input_text_multi_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
44 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
45 <input type="text" name="foo" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
46 </p></form>""") | HTMLFormFiller(data={'foo': ['bar']}) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
47 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
48 <input type="text" name="foo" value="bar"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
49 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
50 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
51 def test_fill_input_hidden_no_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
52 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
53 <input type="hidden" name="foo" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
54 </p></form>""") | HTMLFormFiller() |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
55 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
56 <input type="hidden" name="foo"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
57 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
58 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
59 def test_fill_input_hidden_single_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
60 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
61 <input type="hidden" name="foo" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
62 </p></form>""") | HTMLFormFiller(data={'foo': 'bar'}) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
63 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
64 <input type="hidden" name="foo" value="bar"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
65 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
66 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
67 def test_fill_input_hidden_multi_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
68 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
69 <input type="hidden" name="foo" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
70 </p></form>""") | HTMLFormFiller(data={'foo': ['bar']}) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
71 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
72 <input type="hidden" name="foo" value="bar"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
73 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
74 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
75 def test_fill_textarea_no_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
76 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
77 <textarea name="foo"></textarea> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
78 </p></form>""") | HTMLFormFiller() |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
79 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
80 <textarea name="foo"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
81 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
82 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
83 def test_fill_textarea_single_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
84 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
85 <textarea name="foo"></textarea> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
86 </p></form>""") | HTMLFormFiller(data={'foo': 'bar'}) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
87 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
88 <textarea name="foo">bar</textarea> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
89 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
90 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
91 def test_fill_textarea_multi_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
92 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
93 <textarea name="foo"></textarea> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
94 </p></form>""") | HTMLFormFiller(data={'foo': ['bar']}) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
95 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
96 <textarea name="foo">bar</textarea> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
97 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
98 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
99 def test_fill_input_checkbox_no_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
100 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
101 <input type="checkbox" name="foo" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
102 </p></form>""") | HTMLFormFiller() |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
103 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
104 <input type="checkbox" name="foo"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
105 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
106 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
107 def test_fill_input_checkbox_single_value_auto(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
108 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
109 <input type="checkbox" name="foo" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
110 </p></form>""") |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
111 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
112 <input type="checkbox" name="foo"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
113 </p></form>""", unicode(html | HTMLFormFiller(data={'foo': ''}))) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
114 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
115 <input type="checkbox" name="foo" checked="checked"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
116 </p></form>""", unicode(html | HTMLFormFiller(data={'foo': 'on'}))) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
117 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
118 def test_fill_input_checkbox_single_value_defined(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
119 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
120 <input type="checkbox" name="foo" value="1" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
121 </p></form>""") |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
122 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
123 <input type="checkbox" name="foo" value="1" checked="checked"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
124 </p></form>""", unicode(html | HTMLFormFiller(data={'foo': '1'}))) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
125 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
126 <input type="checkbox" name="foo" value="1"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
127 </p></form>""", unicode(html | HTMLFormFiller(data={'foo': '2'}))) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
128 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
129 def test_fill_input_checkbox_multi_value_auto(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
130 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
131 <input type="checkbox" name="foo" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
132 </p></form>""") |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
133 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
134 <input type="checkbox" name="foo"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
135 </p></form>""", unicode(html | HTMLFormFiller(data={'foo': []}))) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
136 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
137 <input type="checkbox" name="foo" checked="checked"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
138 </p></form>""", unicode(html | HTMLFormFiller(data={'foo': ['on']}))) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
139 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
140 def test_fill_input_checkbox_multi_value_defined(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
141 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
142 <input type="checkbox" name="foo" value="1" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
143 </p></form>""") |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
144 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
145 <input type="checkbox" name="foo" value="1" checked="checked"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
146 </p></form>""", unicode(html | HTMLFormFiller(data={'foo': ['1']}))) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
147 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
148 <input type="checkbox" name="foo" value="1"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
149 </p></form>""", unicode(html | HTMLFormFiller(data={'foo': ['2']}))) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
150 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
151 def test_fill_input_radio_no_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
152 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
153 <input type="radio" name="foo" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
154 </p></form>""") | HTMLFormFiller() |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
155 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
156 <input type="radio" name="foo"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
157 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
158 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
159 def test_fill_input_radio_single_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
160 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
161 <input type="radio" name="foo" value="1" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
162 </p></form>""") |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
163 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
164 <input type="radio" name="foo" value="1" checked="checked"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
165 </p></form>""", unicode(html | HTMLFormFiller(data={'foo': '1'}))) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
166 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
167 <input type="radio" name="foo" value="1"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
168 </p></form>""", unicode(html | HTMLFormFiller(data={'foo': '2'}))) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
169 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
170 def test_fill_input_radio_multi_value(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
171 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
172 <input type="radio" name="foo" value="1" /> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
173 </p></form>""") |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
174 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
175 <input type="radio" name="foo" value="1" checked="checked"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
176 </p></form>""", unicode(html | HTMLFormFiller(data={'foo': ['1']}))) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
177 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
178 <input type="radio" name="foo" value="1"/> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
179 </p></form>""", unicode(html | HTMLFormFiller(data={'foo': ['2']}))) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
180 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
181 def test_fill_select_no_value_auto(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
182 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
183 <select name="foo"> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
184 <option>1</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
185 <option>2</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
186 <option>3</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
187 </select> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
188 </p></form>""") | HTMLFormFiller() |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
189 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
190 <select name="foo"> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
191 <option>1</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
192 <option>2</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
193 <option>3</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
194 </select> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
195 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
196 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
197 def test_fill_select_no_value_defined(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
198 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
199 <select name="foo"> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
200 <option value="1">1</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
201 <option value="2">2</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
202 <option value="3">3</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
203 </select> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
204 </p></form>""") | HTMLFormFiller() |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
205 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
206 <select name="foo"> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
207 <option value="1">1</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
208 <option value="2">2</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
209 <option value="3">3</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
210 </select> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
211 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
212 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
213 def test_fill_select_single_value_auto(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
214 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
215 <select name="foo"> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
216 <option>1</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
217 <option>2</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
218 <option>3</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
219 </select> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
220 </p></form>""") | HTMLFormFiller(data={'foo': '1'}) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
221 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
222 <select name="foo"> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
223 <option selected="selected">1</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
224 <option>2</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
225 <option>3</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
226 </select> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
227 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
228 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
229 def test_fill_select_single_value_defined(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
230 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
231 <select name="foo"> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
232 <option value="1">1</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
233 <option value="2">2</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
234 <option value="3">3</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
235 </select> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
236 </p></form>""") | HTMLFormFiller(data={'foo': '1'}) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
237 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
238 <select name="foo"> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
239 <option value="1" selected="selected">1</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
240 <option value="2">2</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
241 <option value="3">3</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
242 </select> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
243 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
244 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
245 def test_fill_select_multi_value_auto(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
246 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
247 <select name="foo" multiple> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
248 <option>1</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
249 <option>2</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
250 <option>3</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
251 </select> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
252 </p></form>""") | HTMLFormFiller(data={'foo': ['1', '3']}) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
253 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
254 <select name="foo" multiple="multiple"> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
255 <option selected="selected">1</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
256 <option>2</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
257 <option selected="selected">3</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
258 </select> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
259 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
260 |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
261 def test_fill_select_multi_value_defined(self): |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
262 html = HTML("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
263 <select name="foo" multiple> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
264 <option value="1">1</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
265 <option value="2">2</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
266 <option value="3">3</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
267 </select> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
268 </p></form>""") | HTMLFormFiller(data={'foo': ['1', '3']}) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
269 self.assertEquals("""<form><p> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
270 <select name="foo" multiple="multiple"> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
271 <option value="1" selected="selected">1</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
272 <option value="2">2</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
273 <option value="3" selected="selected">3</option> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
274 </select> |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
275 </p></form>""", unicode(html)) |
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
276 |
584
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
277 def test_fill_option_segmented_text(self): |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
278 html = MarkupTemplate("""<form> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
279 <select name="foo"> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
280 <option value="1">foo $x</option> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
281 </select> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
282 </form>""").generate(x=1) | HTMLFormFiller(data={'foo': '1'}) |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
283 self.assertEquals("""<form> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
284 <select name="foo"> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
285 <option value="1" selected="selected">foo 1</option> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
286 </select> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
287 </form>""", unicode(html)) |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
288 |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
289 def test_fill_option_segmented_text_no_value(self): |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
290 html = MarkupTemplate("""<form> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
291 <select name="foo"> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
292 <option>foo $x bar</option> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
293 </select> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
294 </form>""").generate(x=1) | HTMLFormFiller(data={'foo': 'foo 1 bar'}) |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
295 self.assertEquals("""<form> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
296 <select name="foo"> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
297 <option selected="selected">foo 1 bar</option> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
298 </select> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
299 </form>""", unicode(html)) |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
300 |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
301 def test_fill_option_unicode_value(self): |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
302 html = HTML(u"""<form> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
303 <select name="foo"> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
304 <option value="ö">foo</option> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
305 </select> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
306 </form>""") | HTMLFormFiller(data={'foo': u'ö'}) |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
307 self.assertEquals(u"""<form> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
308 <select name="foo"> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
309 <option value="ö" selected="selected">foo</option> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
310 </select> |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
311 </form>""", unicode(html)) |
84137a71a4ca
Fixed a few cases where HTMLFormFiller didn't work well with option elements:
jonas
parents:
571
diff
changeset
|
312 |
275
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
313 |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
314 class HTMLSanitizerTestCase(unittest.TestCase): |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
315 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
316 def test_sanitize_unchanged(self): |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
317 html = HTML('<a href="#">fo<br />o</a>') |
144
28b56f09a7e1
* Coalesce adjacent text events that the parsers would produce when text crossed the buffer boundaries. Fixes #26.
cmlenz
parents:
115
diff
changeset
|
318 self.assertEquals(u'<a href="#">fo<br/>o</a>', |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
319 unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
320 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
321 def test_sanitize_escape_text(self): |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
322 html = HTML('<a href="#">fo&</a>') |
144
28b56f09a7e1
* Coalesce adjacent text events that the parsers would produce when text crossed the buffer boundaries. Fixes #26.
cmlenz
parents:
115
diff
changeset
|
323 self.assertEquals(u'<a href="#">fo&</a>', |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
324 unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
325 html = HTML('<a href="#"><foo></a>') |
144
28b56f09a7e1
* Coalesce adjacent text events that the parsers would produce when text crossed the buffer boundaries. Fixes #26.
cmlenz
parents:
115
diff
changeset
|
326 self.assertEquals(u'<a href="#"><foo></a>', |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
327 unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
328 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
329 def test_sanitize_entityref_text(self): |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
330 html = HTML('<a href="#">foö</a>') |
144
28b56f09a7e1
* Coalesce adjacent text events that the parsers would produce when text crossed the buffer boundaries. Fixes #26.
cmlenz
parents:
115
diff
changeset
|
331 self.assertEquals(u'<a href="#">foö</a>', |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
332 unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
333 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
334 def test_sanitize_escape_attr(self): |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
335 html = HTML('<div title="<foo>"></div>') |
144
28b56f09a7e1
* Coalesce adjacent text events that the parsers would produce when text crossed the buffer boundaries. Fixes #26.
cmlenz
parents:
115
diff
changeset
|
336 self.assertEquals(u'<div title="<foo>"/>', |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
337 unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
338 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
339 def test_sanitize_close_empty_tag(self): |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
340 html = HTML('<a href="#">fo<br>o</a>') |
144
28b56f09a7e1
* Coalesce adjacent text events that the parsers would produce when text crossed the buffer boundaries. Fixes #26.
cmlenz
parents:
115
diff
changeset
|
341 self.assertEquals(u'<a href="#">fo<br/>o</a>', |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
342 unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
343 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
344 def test_sanitize_invalid_entity(self): |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
345 html = HTML('&junk;') |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
346 self.assertEquals('&junk;', unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
347 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
348 def test_sanitize_remove_script_elem(self): |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
349 html = HTML('<script>alert("Foo")</script>') |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
350 self.assertEquals(u'', unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
351 html = HTML('<SCRIPT SRC="http://example.com/"></SCRIPT>') |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
352 self.assertEquals(u'', unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
353 self.assertRaises(ParseError, HTML, '<SCR\0IPT>alert("foo")</SCR\0IPT>') |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
354 self.assertRaises(ParseError, HTML, |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
355 '<SCRIPT&XYZ SRC="http://example.com/"></SCRIPT>') |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
356 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
357 def test_sanitize_remove_onclick_attr(self): |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
358 html = HTML('<div onclick=\'alert("foo")\' />') |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
359 self.assertEquals(u'<div/>', unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
360 |
571
5815ad5f75a4
* Cleaned up the implementation of the `HTMLSanitizer`.
cmlenz
parents:
556
diff
changeset
|
361 def test_sanitize_remove_comments(self): |
5815ad5f75a4
* Cleaned up the implementation of the `HTMLSanitizer`.
cmlenz
parents:
556
diff
changeset
|
362 html = HTML('''<div><!-- conditional comment crap --></div>''') |
5815ad5f75a4
* Cleaned up the implementation of the `HTMLSanitizer`.
cmlenz
parents:
556
diff
changeset
|
363 self.assertEquals(u'<div/>', unicode(html | HTMLSanitizer())) |
5815ad5f75a4
* Cleaned up the implementation of the `HTMLSanitizer`.
cmlenz
parents:
556
diff
changeset
|
364 |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
365 def test_sanitize_remove_style_scripts(self): |
431
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
366 sanitizer = HTMLSanitizer(safe_attrs=HTMLSanitizer.SAFE_ATTRS | set(['style'])) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
367 # Inline style with url() using javascript: scheme |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
368 html = HTML('<DIV STYLE=\'background: url(javascript:alert("foo"))\'>') |
431
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
369 self.assertEquals(u'<div/>', unicode(html | sanitizer)) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
370 # Inline style with url() using javascript: scheme, using control char |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
371 html = HTML('<DIV STYLE=\'background: url(javascript:alert("foo"))\'>') |
431
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
372 self.assertEquals(u'<div/>', unicode(html | sanitizer)) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
373 # Inline style with url() using javascript: scheme, in quotes |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
374 html = HTML('<DIV STYLE=\'background: url("javascript:alert(foo)")\'>') |
431
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
375 self.assertEquals(u'<div/>', unicode(html | sanitizer)) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
376 # IE expressions in CSS not allowed |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
377 html = HTML('<DIV STYLE=\'width: expression(alert("foo"));\'>') |
431
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
378 self.assertEquals(u'<div/>', unicode(html | sanitizer)) |
556
d5cb5c200045
The HTML sanitizer now strips any CSS comments in style attributes, which could previously be used to hide malicious property values.
cmlenz
parents:
446
diff
changeset
|
379 html = HTML('<DIV STYLE=\'width: e/**/xpression(alert("foo"));\'>') |
d5cb5c200045
The HTML sanitizer now strips any CSS comments in style attributes, which could previously be used to hide malicious property values.
cmlenz
parents:
446
diff
changeset
|
380 self.assertEquals(u'<div/>', unicode(html | sanitizer)) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
381 html = HTML('<DIV STYLE=\'background: url(javascript:alert("foo"));' |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
382 'color: #fff\'>') |
144
28b56f09a7e1
* Coalesce adjacent text events that the parsers would produce when text crossed the buffer boundaries. Fixes #26.
cmlenz
parents:
115
diff
changeset
|
383 self.assertEquals(u'<div style="color: #fff"/>', |
431
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
384 unicode(html | sanitizer)) |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
385 # Inline style with url() using javascript: scheme, using unicode |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
386 # escapes |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
387 html = HTML('<DIV STYLE=\'background: \\75rl(javascript:alert("foo"))\'>') |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
388 self.assertEquals(u'<div/>', unicode(html | sanitizer)) |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
389 html = HTML('<DIV STYLE=\'background: \\000075rl(javascript:alert("foo"))\'>') |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
390 self.assertEquals(u'<div/>', unicode(html | sanitizer)) |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
391 html = HTML('<DIV STYLE=\'background: \\75 rl(javascript:alert("foo"))\'>') |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
392 self.assertEquals(u'<div/>', unicode(html | sanitizer)) |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
393 html = HTML('<DIV STYLE=\'background: \\000075 rl(javascript:alert("foo"))\'>') |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
394 self.assertEquals(u'<div/>', unicode(html | sanitizer)) |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
395 html = HTML('<DIV STYLE=\'background: \\000075\r\nrl(javascript:alert("foo"))\'>') |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
396 self.assertEquals(u'<div/>', unicode(html | sanitizer)) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
397 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
398 def test_sanitize_remove_src_javascript(self): |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
399 html = HTML('<img src=\'javascript:alert("foo")\'>') |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
400 self.assertEquals(u'<img/>', unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
401 # Case-insensitive protocol matching |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
402 html = HTML('<IMG SRC=\'JaVaScRiPt:alert("foo")\'>') |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
403 self.assertEquals(u'<img/>', unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
404 # Grave accents (not parsed) |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
405 self.assertRaises(ParseError, HTML, |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
406 '<IMG SRC=`javascript:alert("RSnake says, \'foo\'")`>') |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
407 # Protocol encoded using UTF-8 numeric entities |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
408 html = HTML('<IMG SRC=\'javascri' |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
409 'pt:alert("foo")\'>') |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
410 self.assertEquals(u'<img/>', unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
411 # Protocol encoded using UTF-8 numeric entities without a semicolon |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
412 # (which is allowed because the max number of digits is used) |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
413 html = HTML('<IMG SRC=\'java' |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
414 'script' |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
415 ':alert("foo")\'>') |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
416 self.assertEquals(u'<img/>', unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
417 # Protocol encoded using UTF-8 numeric hex entities without a semicolon |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
418 # (which is allowed because the max number of digits is used) |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
419 html = HTML('<IMG SRC=\'javascri' |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
420 'pt:alert("foo")\'>') |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
421 self.assertEquals(u'<img/>', unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
422 # Embedded tab character in protocol |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
423 html = HTML('<IMG SRC=\'jav\tascript:alert("foo");\'>') |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
424 self.assertEquals(u'<img/>', unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
425 # Embedded tab character in protocol, but encoded this time |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
426 html = HTML('<IMG SRC=\'jav	ascript:alert("foo");\'>') |
204
516a6cae0aa8
* Implement reverse add/mul operators for `Markup` class, so that the result is also a `Markup` instance.
cmlenz
parents:
144
diff
changeset
|
427 self.assertEquals(u'<img/>', unicode(html | HTMLSanitizer())) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
428 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
429 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
430 def suite(): |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
431 suite = unittest.TestSuite() |
446
90f5908cd10a
Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
431
diff
changeset
|
432 suite.addTest(doctest.DocTestSuite(HTMLFormFiller.__module__)) |
275
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
433 suite.addTest(unittest.makeSuite(HTMLFormFillerTestCase, 'test')) |
113
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
434 suite.addTest(unittest.makeSuite(HTMLSanitizerTestCase, 'test')) |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
435 return suite |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
436 |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
437 if __name__ == '__main__': |
e815c2c07572
Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
cmlenz
parents:
diff
changeset
|
438 unittest.main(defaultTest='suite') |