~pythoneers/ubuntu/lucid/lxml/ltsppa

« back to all changes in this revision

Viewing changes to src/lxml/html/tests/test_clean_embed.txt

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-01-03 14:14:10 UTC
  • mfrom: (1.1.22 upstream) (2.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100103141410-an8068uw705flim6
Tags: 2.2.4-1
* New upstream version.
* Build a python-lxml-doc package. Closes: #488258.
* Tighten build dependency. Closes: #551698.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
>>> from lxml.html.clean import clean, clean_html, Cleaner
6
6
>>> from lxml.html import usedoctest
7
7
 
 
8
>>> def tostring(el):  # work-around for Py3 'bytes' type
 
9
...     from lxml.html import tostring
 
10
...     s = tostring(el)
 
11
...     if not isinstance(s, str):
 
12
...         s = s.decode('UTF-8')
 
13
...     return s
 
14
 
8
15
>>> doc_embed = '''<div>
9
16
... <embed src="http://www.youtube.com/v/183tVH1CZpA" type="application/x-shockwave-flash"></embed>
10
17
... <embed src="http://anothersite.com/v/another"></embed>
11
18
... <script src="http://www.youtube.com/example.js"></script>
12
19
... <script src="/something-else.js"></script>
13
20
... </div>'''
14
 
>>> print tostring(fromstring(doc_embed))
 
21
>>> print(tostring(fromstring(doc_embed)))
15
22
<div>
16
23
<embed src="http://www.youtube.com/v/183tVH1CZpA" type="application/x-shockwave-flash"></embed>
17
24
<embed src="http://anothersite.com/v/another"></embed>
18
25
<script src="http://www.youtube.com/example.js"></script>
19
26
<script src="/something-else.js"></script>
20
27
</div>
21
 
>>> print Cleaner().clean_html(doc_embed)
 
28
>>> print(Cleaner().clean_html(doc_embed))
22
29
<div>
23
30
</div>
24
 
>>> print Cleaner(host_whitelist=['www.youtube.com']).clean_html(doc_embed)
 
31
>>> print(Cleaner(host_whitelist=['www.youtube.com']).clean_html(doc_embed))
25
32
<div>
26
33
<embed src="http://www.youtube.com/v/183tVH1CZpA" type="application/x-shockwave-flash"></embed>
27
34
</div>
28
 
>>> print Cleaner(host_whitelist=['www.youtube.com'], whitelist_tags=None).clean_html(doc_embed)
 
35
>>> print(Cleaner(host_whitelist=['www.youtube.com'], whitelist_tags=None).clean_html(doc_embed))
29
36
<div>
30
37
<embed src="http://www.youtube.com/v/183tVH1CZpA" type="application/x-shockwave-flash"></embed>
31
38
<script src="http://www.youtube.com/example.js"></script>