Skip to content

Commit 9a917e1

Browse files
committed
Start work on supporting testing of beautifulsoup
Change original dehtml only test into a method to be called by a test method. Converter to be used is passed in and selects the right comparison text. All this change does is set things up to run the dehtml test parameterized. It also provdes the stub for the beautiful soup test.
1 parent 0cc609a commit 9a917e1

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

test/test_mailgw.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,22 +1381,33 @@ def testMultipartRFC822(self):
13811381
--001485f339f8f361fb049188dbba--
13821382
'''%html_doc
13831383

1384-
def testMultipartTextifyHTML(self):
1385-
text_fragments = ['Roundup\n Home\nDownload\nDocs\nRoundup Features\nInstalling Roundup\nUpgrading to newer versions of Roundup\nRoundup FAQ\nUser Guide\nCustomising Roundup\nAdministration Guide\nPrerequisites\n\nRoundup requires Python 2.5 or newer (but not Python 3) with a functioning\nanydbm module. Download the latest version from http://www.python.org/.\nIt is highly recommended that users install the latest patch version\nof python as these contain many fixes to serious bugs.\n\nSome variants of Linux will need an additional ', ('python dev', u2s(u'\u201cpython dev\u201d')), ' package\ninstalled for Roundup installation to work. Debian and derivatives, are\nknown to require this.\n\nIf you', (u2s(u'\u2019'), ''), 're on windows, you will either need to be using the ActiveState python\ndistribution (at http://www.activestate.com/Products/ActivePython/), or you', (u2s(u'\u2019'), ''), 'll\nhave to install the win32all package separately (get it from\nhttp://starship.python.net/crew/mhammond/win32/).\n\numlaut']
1384+
def disabletestMultipartTextifyHTMLBeautifulSoup(self):
1385+
self.maxDiff = None
1386+
self.MultipartTextifyHTML(converter="beautifulsoup")
1387+
1388+
def testMultipartTextifyHTMLDehtml(self):
1389+
self.MultipartTextifyHTML(converter="dehtml")
1390+
1391+
def MultipartTextifyHTML(self, converter='dehtml'):
1392+
text_fragments = {}
1393+
text_fragments['dehtml'] = ['Roundup\n Home\nDownload\nDocs\nRoundup Features\nInstalling Roundup\nUpgrading to newer versions of Roundup\nRoundup FAQ\nUser Guide\nCustomising Roundup\nAdministration Guide\nPrerequisites\n\nRoundup requires Python 2.5 or newer (but not Python 3) with a functioning\nanydbm module. Download the latest version from http://www.python.org/.\nIt is highly recommended that users install the latest patch version\nof python as these contain many fixes to serious bugs.\n\nSome variants of Linux will need an additional ', ('python dev', u2s(u'\u201cpython dev\u201d')), ' package\ninstalled for Roundup installation to work. Debian and derivatives, are\nknown to require this.\n\nIf you', (u2s(u'\u2019'), ''), 're on windows, you will either need to be using the ActiveState python\ndistribution (at http://www.activestate.com/Products/ActivePython/), or you', (u2s(u'\u2019'), ''), 'll\nhave to install the win32all package separately (get it from\nhttp://starship.python.net/crew/mhammond/win32/).\n\numlaut'] + [b2s(b" \xc3\xa4\xc3\xb6\xc3\xbc\xc3\x84\xc3\x96\xc3\x9c\xc3\x9f")]
13861394

13871395
# \xc3\xa4\xc3\xb6\xc3\xbc\xc3\x84\xc3\x96\xc3\x9c\xc3\x9f
13881396
# append above with leading space to end of mycontent. It is the
13891397
# translated content when =E4=F6=FC=C4=D6=DC=DF is added to the html
13901398
# input.
13911399
self.doNewIssue()
1392-
self.db.config.MAILGW_CONVERT_HTMLTOTEXT = 'dehtml'
1400+
self.db.config.MAILGW_CONVERT_HTMLTOTEXT = converter
13931401
self._handle_mail(self.multipart_msg_notext)
13941402
messages = self.db.issue.get('1', 'messages')
13951403
messages.sort()
13961404
msg = self.db.msg.getnode(messages[-1])
1405+
1406+
print(msg.content)
1407+
print(text_fragments[converter][0])
13971408
# html converted to utf-8 text
13981409
self.compareStringFragments(msg.content,
1399-
text_fragments + [b2s(b" \xc3\xa4\xc3\xb6\xc3\xbc\xc3\x84\xc3\x96\xc3\x9c\xc3\x9f")])
1410+
text_fragments[converter])
14001411
self.assertEqual(msg.type, None)
14011412
self.assertEqual(len(msg.files), 2)
14021413
name = "unnamed" # no name for any files

0 commit comments

Comments
 (0)