author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 22 Oct 2010 14:28:09 +0200 | |
changeset 6588 | f8320a8c3c9d |
parent 6366 | 1806148d6ce8 |
child 6685 | eeedb3575d25 |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: utf-8 -*- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
2 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
3 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
4 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
5 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
6 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
7 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
8 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
9 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
10 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
11 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
12 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
13 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
14 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
15 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
16 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
17 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
18 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
6153
ade53a90ddf1
remove useless import
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
19 |
"""unittests for cubicweb.uilib""" |
0 | 20 |
|
21 |
__docformat__ = "restructuredtext en" |
|
22 |
||
23 |
from logilab.common.testlib import TestCase, unittest_main |
|
24 |
||
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3002
diff
changeset
|
25 |
from cubicweb import uilib |
0 | 26 |
|
27 |
class UILIBTC(TestCase): |
|
28 |
||
29 |
def test_remove_tags(self): |
|
30 |
"""make sure remove_tags remove all tags""" |
|
31 |
data = [ |
|
32 |
('<h1>Hello</h1>', 'Hello'), |
|
33 |
('<h1>Hello <a href="foo/bar"><b>s</b>pam</a></h1>', 'Hello spam'), |
|
34 |
('<br>Hello<img src="doh.png"/>', 'Hello'), |
|
35 |
('<p></p>', ''), |
|
36 |
] |
|
37 |
for text, expected in data: |
|
38 |
got = uilib.remove_html_tags(text) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
39 |
self.assertEqual(got, expected) |
1646 | 40 |
|
350
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
41 |
def test_fallback_safe_cut(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
42 |
self.assertEqual(uilib.fallback_safe_cut(u'ab <a href="hello">cd</a>', 4), u'ab c...') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
43 |
self.assertEqual(uilib.fallback_safe_cut(u'ab <a href="hello">cd</a>', 5), u'ab <a href="hello">cd</a>') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
44 |
self.assertEqual(uilib.fallback_safe_cut(u'ab <a href="hello">&d</a>', 4), u'ab &...') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
45 |
self.assertEqual(uilib.fallback_safe_cut(u'ab <a href="hello">&d</a> ef', 5), u'ab &d...') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
46 |
self.assertEqual(uilib.fallback_safe_cut(u'ab <a href="hello">ìd</a>', 4), u'ab ì...') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
47 |
self.assertEqual(uilib.fallback_safe_cut(u'& <a href="hello">&d</a> ef', 4), u'& &d...') |
1646 | 48 |
|
350
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
49 |
def test_lxml_safe_cut(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
50 |
self.assertEqual(uilib.safe_cut(u'aaa<div>aaad</div> ef', 4), u'<p>aaa</p><div>a...</div>') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
51 |
self.assertEqual(uilib.safe_cut(u'aaa<div>aaad</div> ef', 7), u'<p>aaa</p><div>aaad</div>...') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
52 |
self.assertEqual(uilib.safe_cut(u'aaa<div>aaad</div>', 7), u'<p>aaa</p><div>aaad</div>') |
350
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
53 |
# Missing ellipsis due to space management but we don't care |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
54 |
self.assertEqual(uilib.safe_cut(u'ab <a href="hello">&d</a>', 4), u'<p>ab <a href="hello">&...</a></p>') |
0 | 55 |
|
56 |
def test_cut(self): |
|
160
cf9ab83b1cf3
adding tests for safe_cut (and text_cut_letters)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
57 |
"""tests uilib.cut() behaviour""" |
0 | 58 |
data = [ |
59 |
('hello', 'hello'), |
|
350
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
60 |
('hello world', 'hello wo...'), |
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
61 |
("hell<b>O'</b> world", "hell<b>O..."), |
0 | 62 |
] |
63 |
for text, expected in data: |
|
64 |
got = uilib.cut(text, 8) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
65 |
self.assertEqual(got, expected) |
0 | 66 |
|
350
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
67 |
def test_text_cut(self): |
0 | 68 |
"""tests uilib.text_cut() behaviour with no text""" |
350
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
69 |
data = [('',''), |
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
70 |
("""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod |
0 | 71 |
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, |
72 |
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo |
|
73 |
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse |
|
350
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
74 |
cillum dolore eu fugiat nulla pariatur.""", |
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
75 |
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod \ |
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
76 |
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, \ |
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
77 |
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo \ |
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
78 |
consequat."), |
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
79 |
("""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod |
0 | 80 |
tempor incididunt ut labore et dolore magna aliqua Ut enim ad minim veniam, |
81 |
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo |
|
82 |
consequat Duis aute irure dolor in reprehenderit in voluptate velit esse |
|
83 |
cillum dolore eu fugiat nulla pariatur Excepteur sint occaecat cupidatat non |
|
84 |
proident, sunt in culpa qui officia deserunt mollit anim id est laborum |
|
350
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
85 |
""", |
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
86 |
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod \ |
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
87 |
tempor incididunt ut labore et dolore magna aliqua Ut enim ad minim veniam, \ |
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
88 |
quis nostrud exercitation ullamco laboris nisi"), |
f34ef2c64605
cleanup/fix cut variants
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
343
diff
changeset
|
89 |
] |
0 | 90 |
for text, expected in data: |
91 |
got = uilib.text_cut(text, 30) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
92 |
self.assertEqual(got, expected) |
0 | 93 |
|
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
94 |
def test_soup2xhtml_1_1(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
95 |
self.assertEqual(uilib.soup2xhtml('hop <div>', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
96 |
'hop <div/>') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
97 |
self.assertEqual(uilib.soup2xhtml('<div> hop', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
98 |
'<div> hop</div>') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
99 |
self.assertEqual(uilib.soup2xhtml('hop <div> hop', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
100 |
'hop <div> hop</div>') |
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
101 |
|
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
102 |
def test_soup2xhtml_1_2(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
103 |
self.assertEqual(uilib.soup2xhtml('hop </div>', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
104 |
'hop ') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
105 |
self.assertEqual(uilib.soup2xhtml('</div> hop', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
106 |
'<div/> hop') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
107 |
self.assertEqual(uilib.soup2xhtml('hop </div> hop', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
108 |
'<div>hop </div> hop') |
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
109 |
|
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
110 |
def test_soup2xhtml_2_1(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
111 |
self.assertEqual(uilib.soup2xhtml('hop <body>', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
112 |
'hop ') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
113 |
self.assertEqual(uilib.soup2xhtml('<body> hop', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
114 |
' hop') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
115 |
self.assertEqual(uilib.soup2xhtml('hop <body> hop', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
116 |
'hop hop') |
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
117 |
|
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
118 |
def test_soup2xhtml_2_2(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
119 |
self.assertEqual(uilib.soup2xhtml('hop </body>', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
120 |
'hop ') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
121 |
self.assertEqual(uilib.soup2xhtml('</body> hop', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
122 |
' hop') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
123 |
self.assertEqual(uilib.soup2xhtml('hop </body> hop', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
124 |
'hop hop') |
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
125 |
|
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
126 |
def test_soup2xhtml_3_1(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
127 |
self.assertEqual(uilib.soup2xhtml('hop <html>', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
128 |
'hop ') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
129 |
self.assertEqual(uilib.soup2xhtml('<html> hop', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
130 |
' hop') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
131 |
self.assertEqual(uilib.soup2xhtml('hop <html> hop', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
132 |
'hop hop') |
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
133 |
|
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
134 |
def test_soup2xhtml_3_2(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
135 |
self.assertEqual(uilib.soup2xhtml('hop </html>', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
136 |
'hop ') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
137 |
self.assertEqual(uilib.soup2xhtml('</html> hop', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
138 |
' hop') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
139 |
self.assertEqual(uilib.soup2xhtml('hop </html> hop', 'ascii'), |
5730
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
140 |
'hop hop') |
784025c15a3c
[xhtml] fix soup2xhtml to deal with malformed div,body and html tags which may leads to malformed return value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
141 |
|
5949
2a273c896a38
[box] provide a new generic base box class to edit relation to simple entities, backported from the 'tag' cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5730
diff
changeset
|
142 |
def test_js(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
143 |
self.assertEqual(str(uilib.js.pouet(1, "2")), |
5949
2a273c896a38
[box] provide a new generic base box class to edit relation to simple entities, backported from the 'tag' cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5730
diff
changeset
|
144 |
'pouet(1,"2")') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
145 |
self.assertEqual(str(uilib.js.cw.pouet(1, "2")), |
5949
2a273c896a38
[box] provide a new generic base box class to edit relation to simple entities, backported from the 'tag' cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5730
diff
changeset
|
146 |
'cw.pouet(1,"2")') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5949
diff
changeset
|
147 |
self.assertEqual(str(uilib.js.cw.pouet(1, "2").pouet(None)), |
5949
2a273c896a38
[box] provide a new generic base box class to edit relation to simple entities, backported from the 'tag' cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5730
diff
changeset
|
148 |
'cw.pouet(1,"2").pouet(null)') |
2a273c896a38
[box] provide a new generic base box class to edit relation to simple entities, backported from the 'tag' cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5730
diff
changeset
|
149 |
|
0 | 150 |
if __name__ == '__main__': |
151 |
unittest_main() |
|
152 |