From 234bedc1b51af8fce66ff4fbe381d94a08b9509b Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Wed, 29 Dec 2010 16:06:24 -0500 Subject: Ported a whole lot of unit tests to the new system. --- src/beautifulsoup/tests/helpers.py | 10 ++- src/beautifulsoup/tests/test_soup.py | 129 ----------------------------------- 2 files changed, 9 insertions(+), 130 deletions(-) (limited to 'src') diff --git a/src/beautifulsoup/tests/helpers.py b/src/beautifulsoup/tests/helpers.py index fbdcedb..42ec3ec 100644 --- a/src/beautifulsoup/tests/helpers.py +++ b/src/beautifulsoup/tests/helpers.py @@ -44,11 +44,20 @@ class BuilderSmokeTest(SoupTest): # fragment recognizable as the original string. self.assertSoupEquals("A bare string") + def test_mixed_case_tags(self): + # Mixed-case tags are folded to lowercase. + self.assertSoupEquals( + "", + "") + def test_self_closing(self): # HTML's self-closing tags are recognized as such. self.assertSoupEquals( "

A tag

", "

A tag

") + self.assertSoupEquals( + "

Foo
bar

", "

Foo
bar

") + def test_nested_inline_elements(self): # Inline tags can be nested indefinitely. b_tag = "Inside a B tag" @@ -75,7 +84,6 @@ class BuilderSmokeTest(SoupTest): self.assertSoupEquals("
   
") self.assertSoupEquals("") - def test_single_quote_attribute_values_become_double_quotes(self): self.assertSoupEquals("", '') diff --git a/src/beautifulsoup/tests/test_soup.py b/src/beautifulsoup/tests/test_soup.py index 5724247..a371c3f 100644 --- a/src/beautifulsoup/tests/test_soup.py +++ b/src/beautifulsoup/tests/test_soup.py @@ -47,67 +47,6 @@ class FollowThatTag(SoupTest): 4""" self.soup = BeautifulStoneSoup(ml) - def testFindAllByName(self): - matching = self.soup('a') - self.assertEqual(len(matching), 2) - self.assertEqual(matching[0].name, 'a') - self.assertEqual(matching, self.soup.findAll('a')) - self.assertEqual(matching, self.soup.findAll(SoupStrainer('a'))) - - def testFindAllByAttribute(self): - matching = self.soup.findAll(id='x') - self.assertEqual(len(matching), 2) - self.assertEqual(matching[0].name, 'a') - self.assertEqual(matching[1].name, 'b') - - matching2 = self.soup.findAll(attrs={'id' : 'x'}) - self.assertEqual(matching, matching2) - - strainer = SoupStrainer(attrs={'id' : 'x'}) - self.assertEqual(matching, self.soup.findAll(strainer)) - - self.assertEqual(len(self.soup.findAll(id=None)), 1) - - self.assertEqual(len(self.soup.findAll(width=100)), 1) - self.assertEqual(len(self.soup.findAll(junk=None)), 5) - self.assertEqual(len(self.soup.findAll(junk=[1, None])), 5) - - self.assertEqual(len(self.soup.findAll(junk=re.compile('.*'))), 0) - self.assertEqual(len(self.soup.findAll(junk=True)), 0) - - self.assertEqual(len(self.soup.findAll(junk=True)), 0) - self.assertEqual(len(self.soup.findAll(href=True)), 1) - - def testFindallByClass(self): - soup = BeautifulSoup('FooBar') - self.assertEqual(soup.find('a', '1').string, "Bar") - - def testFindAllByList(self): - matching = self.soup(['a', 'ac']) - self.assertEqual(len(matching), 3) - - def testFindAllByHash(self): - matching = self.soup({'a' : True, 'b' : True}) - self.assertEqual(len(matching), 4) - - def testFindAllText(self): - soup = BeautifulSoup("\xbb") - self.assertEqual(soup.findAll(text=re.compile('.*')), - [u'\xbb']) - - def testFindAllByRE(self): - import re - r = re.compile('a.*') - self.assertEqual(len(self.soup(r)), 3) - - def testFindAllByMethod(self): - def matchTagWhereIDMatchesName(tag): - return tag.name == tag.get('id') - - matching = self.soup.findAll(matchTagWhereIDMatchesName) - self.assertEqual(len(matching), 2) - self.assertEqual(matching[0].name, 'a') - def testParents(self): soup = BeautifulSoup('