1 | # -*- coding: utf8 -*- |
---|
2 | from unittest import TestSuite, makeSuite, TestCase |
---|
3 | from quintagroup.seoptimizer.util import unescape |
---|
4 | |
---|
5 | |
---|
6 | class TestUtils(TestCase): |
---|
7 | |
---|
8 | def test_unicode_str_unescaping(self): |
---|
9 | self.assertEqual(unescape("&&-/["), "&&-/[") |
---|
10 | |
---|
11 | def test_str_unescaping(self): |
---|
12 | self.assertEqual(unescape("&&-/["), "&&-/[") |
---|
13 | |
---|
14 | def test_entity_unicode_unescaping(self): |
---|
15 | self.assertEqual(unescape(u"&&ї".encode('utf-8')), |
---|
16 | u"&&ї".encode('utf-8')) |
---|
17 | |
---|
18 | def test_hex_unescaping(self): |
---|
19 | self.assertEqual(unescape('['), '[') |
---|
20 | |
---|
21 | def test_simple_text_unescaping(self): |
---|
22 | self.assertEqual(unescape("Simple text."), "Simple text.") |
---|
23 | |
---|
24 | def test_entity_hex_unescaping(self): |
---|
25 | self.assertEqual(unescape('['), '[') |
---|
26 | |
---|
27 | def test_intity_dec_unescaping(self): |
---|
28 | self.assertEqual(unescape('['), '[') |
---|
29 | |
---|
30 | def test_entity_dec_hex_unescaping(self): |
---|
31 | self.assertEqual(unescape('['), '[') |
---|
32 | |
---|
33 | def test_fake_entity_unescaping(self): |
---|
34 | self.assertEqual(unescape("&asd;"), "&asd;") |
---|
35 | |
---|
36 | def test_aentity_unescaping(self): |
---|
37 | self.assertEqual(unescape("—").encode('utf-8'), |
---|
38 | u"—".encode('utf-8')) |
---|
39 | |
---|
40 | |
---|
41 | def test_suite(): |
---|
42 | suite = TestSuite() |
---|
43 | suite.addTest(makeSuite(TestUtils)) |
---|
44 | return suite |
---|