Mercurial > genshi > genshi-test
annotate genshi/filters/tests/html.py @ 842:b09f746b4881 stable-0.5.x
Ported [1050] to 0.5.x branch.
author | cmlenz |
---|---|
date | Tue, 17 Mar 2009 18:06:31 +0000 |
parents | 85a61d0bd67b |
children |
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 # |
719 | 3 # Copyright (C) 2006-2008 Edgewall Software |
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
|
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 |
842 | 313 def test_fill_input_password_disabled(self): |
314 html = HTML("""<form><p> | |
315 <input type="password" name="pass" /> | |
316 </p></form>""") | HTMLFormFiller(data={'pass': 'bar'}) | |
317 self.assertEquals("""<form><p> | |
318 <input type="password" name="pass"/> | |
319 </p></form>""", unicode(html)) | |
320 | |
321 def test_fill_input_password_enabled(self): | |
322 html = HTML("""<form><p> | |
323 <input type="password" name="pass" /> | |
324 </p></form>""") | HTMLFormFiller(data={'pass': '1234'}, passwords=True) | |
325 self.assertEquals("""<form><p> | |
326 <input type="password" name="pass" value="1234"/> | |
327 </p></form>""", unicode(html)) | |
328 | |
275
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
329 |
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
|
330 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
|
331 |
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
|
332 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
|
333 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
|
334 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
|
335 unicode(html | HTMLSanitizer())) |
839 | 336 html = HTML('<a href="#with:colon">foo</a>') |
337 self.assertEquals(u'<a href="#with:colon">foo</a>', | |
338 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
|
339 |
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 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
|
341 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
|
342 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
|
343 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
|
344 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
|
345 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
|
346 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_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
|
349 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
|
350 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
|
351 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
|
352 |
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 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
|
354 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
|
355 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
|
356 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
|
357 |
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 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
|
359 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
|
360 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
|
361 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
|
362 |
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
|
363 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
|
364 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
|
365 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
|
366 |
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 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
|
368 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
|
369 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
|
370 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
|
371 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
|
372 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
|
373 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
|
374 '<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
|
375 |
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 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
|
377 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
|
378 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
|
379 |
571
5815ad5f75a4
* Cleaned up the implementation of the `HTMLSanitizer`.
cmlenz
parents:
556
diff
changeset
|
380 def test_sanitize_remove_comments(self): |
5815ad5f75a4
* Cleaned up the implementation of the `HTMLSanitizer`.
cmlenz
parents:
556
diff
changeset
|
381 html = HTML('''<div><!-- conditional comment crap --></div>''') |
5815ad5f75a4
* Cleaned up the implementation of the `HTMLSanitizer`.
cmlenz
parents:
556
diff
changeset
|
382 self.assertEquals(u'<div/>', unicode(html | HTMLSanitizer())) |
5815ad5f75a4
* Cleaned up the implementation of the `HTMLSanitizer`.
cmlenz
parents:
556
diff
changeset
|
383 |
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
|
384 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
|
385 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
|
386 # 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
|
387 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
|
388 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
|
389 # 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
|
390 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
|
391 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
|
392 # 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
|
393 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
|
394 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
|
395 # 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
|
396 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
|
397 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
|
398 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
|
399 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
|
400 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
|
401 '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
|
402 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
|
403 unicode(html | sanitizer)) |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
404 # 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
|
405 # escapes |
747baa1cd597
* Don't allow `style` attributes by default in the `HTMLSanitizer`. Closes #97.
cmlenz
parents:
363
diff
changeset
|
406 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
|
407 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
|
408 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
|
409 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
|
410 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
|
411 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
|
412 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
|
413 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
|
414 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
|
415 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
|
416 |
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 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
|
418 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
|
419 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
|
420 # 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
|
421 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
|
422 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
|
423 # 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
|
424 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
|
425 '<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
|
426 # 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
|
427 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
|
428 '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
|
429 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
|
430 # 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
|
431 # (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
|
432 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
|
433 '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
|
434 ':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
|
435 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
|
436 # 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
|
437 # (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
|
438 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
|
439 '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
|
440 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
|
441 # 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
|
442 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
|
443 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
|
444 # 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
|
445 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
|
446 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
|
447 |
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
|
448 |
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
|
449 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
|
450 suite = unittest.TestSuite() |
446
90f5908cd10a
Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
431
diff
changeset
|
451 suite.addTest(doctest.DocTestSuite(HTMLFormFiller.__module__)) |
275
7f24dd6fb904
Integrated `HTMLFormFiller` filter initially presented as a [wiki:FormFilling#Usingatemplatefilter recipe].
cmlenz
parents:
258
diff
changeset
|
452 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
|
453 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
|
454 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
|
455 |
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
|
456 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
|
457 unittest.main(defaultTest='suite') |