From 3e79613458960499d2bce45d4db0d0e96d8e2ffe Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Wed, 29 Dec 2010 18:34:23 -0500 Subject: Wrangled some encoding conversion tests out of the old test file. --- src/beautifulsoup/tests/helpers.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/beautifulsoup/tests/helpers.py') diff --git a/src/beautifulsoup/tests/helpers.py b/src/beautifulsoup/tests/helpers.py index 42ec3ec..c62bb48 100644 --- a/src/beautifulsoup/tests/helpers.py +++ b/src/beautifulsoup/tests/helpers.py @@ -13,9 +13,16 @@ class SoupTest(unittest.TestCase): # test suites that override default_builder. self.default_builder = LXMLTreeBuilder() - def soup(self, markup): + def soup(self, markup, **kwargs): """Build a Beautiful Soup object from markup.""" - return BeautifulSoup(markup, builder=self.default_builder) + return BeautifulSoup(markup, builder=self.default_builder, **kwargs) + + def document_for(self, markup): + """Turn an HTML fragment into a document. + + The details depend on the builder. + """ + return self.default_builder.test_fragment_to_document(markup) def assertSoupEquals(self, to_parse, compare_parsed_to=None): builder = self.default_builder @@ -23,9 +30,7 @@ class SoupTest(unittest.TestCase): if compare_parsed_to is None: compare_parsed_to = to_parse - self.assertEquals( - obj.decode(), - builder.test_fragment_to_document(compare_parsed_to)) + self.assertEquals(obj.decode(), self.document_for(compare_parsed_to)) -- cgit v1.2.3