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/test_soup.py | 711 +++-------------------------------- 1 file changed, 54 insertions(+), 657 deletions(-) (limited to 'src/beautifulsoup/tests/test_soup.py') diff --git a/src/beautifulsoup/tests/test_soup.py b/src/beautifulsoup/tests/test_soup.py index a371c3f..f8d3970 100644 --- a/src/beautifulsoup/tests/test_soup.py +++ b/src/beautifulsoup/tests/test_soup.py @@ -1,671 +1,68 @@ # -*- coding: utf-8 -*- -"""Unit tests for Beautiful Soup. +"""Tests of Beautiful Soup as a whole.""" -These tests make sure the Beautiful Soup works as it should. If you -find a bug in Beautiful Soup, the best way to express it is as a test -case like this that fails.""" - -import re import unittest -from beautifulsoup import * -from beautifulsoup.element import CData, Comment, Declaration, SoupStrainer, Tag +from helpers import SoupTest from beautifulsoup.dammit import UnicodeDammit -from beautifulsoup.builder.html5lib_builder import HTML5TreeBuilder - -def additional_tests(): - return unittest.TestLoader().loadTestsFromName(__name__) - - -class SoupTest(unittest.TestCase): - - default_builder = HTML5TreeBuilder() - - def assertSoupEquals(self, toParse, rep=None, builder=None, - encoding=None): - """Parse the given text and make sure its string rep is the other - given text.""" - if rep == None: - rep = toParse - obj = BeautifulSoup(toParse, builder=self.default_builder) - if encoding is None: - rep2 = obj.decode() - else: - rep2 = obj.encode(encoding) - self.assertEqual(rep2, rep) - - -class FollowThatTag(SoupTest): - "Tests the various ways of fetching tags from a soup." +class TestEncodingConversion(SoupTest): + # Test Beautiful Soup's ability to decode and encode from various + # encodings. def setUp(self): - ml = """ - 1 - 2 - 3 - 4 - 4""" - self.soup = BeautifulStoneSoup(ml) - - def testParents(self): - soup = BeautifulSoup('