diff options
Diffstat (limited to 'bs4/tests/test_tree.py')
-rw-r--r-- | bs4/tests/test_tree.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py index 883cd8a..f1af6ce 100644 --- a/bs4/tests/test_tree.py +++ b/bs4/tests/test_tree.py @@ -1,4 +1,3 @@ - # -*- coding: utf-8 -*- """Tests for Beautiful Soup's tree traversal methods. @@ -1783,7 +1782,7 @@ class TestSoupSelector(TreeTest): self.assertEqual(len(self.soup.select('del')), 0) def test_invalid_tag(self): - self.assertRaises(ValueError, self.soup.select, 'tag%t') + self.assertRaises(SyntaxError, self.soup.select, 'tag%t') def test_select_dashed_tag_ids(self): self.assertSelects('custom-dashed-tag', ['dash1', 'dash2']) @@ -1974,8 +1973,7 @@ class TestSoupSelector(TreeTest): NotImplementedError, self.soup.select, "a:no-such-pseudoclass") self.assertRaises( - NotImplementedError, self.soup.select, "a:nth-of-type(a)") - + SyntaxError, self.soup.select, "a:nth-of-type(a)") def test_nth_of_type(self): # Try to select first paragraph @@ -1992,9 +1990,9 @@ class TestSoupSelector(TreeTest): els = self.soup.select('div#inner p:nth-of-type(4)') self.assertEqual(len(els), 0) - # Pass in an invalid value. - self.assertRaises( - ValueError, self.soup.select, 'div p:nth-of-type(0)') + # Zero will select no tags. + els = self.soup.select('div p:nth-of-type(0)') + self.assertEqual(len(els), 0) def test_nth_of_type_direct_descendant(self): els = self.soup.select('div#inner > p:nth-of-type(1)') @@ -2031,7 +2029,7 @@ class TestSoupSelector(TreeTest): self.assertEqual([], self.soup.select('#inner ~ h2')) def test_dangling_combinator(self): - self.assertRaises(ValueError, self.soup.select, 'h1 >') + self.assertRaises(SyntaxError, self.soup.select, 'h1 >') def test_sibling_combinator_wont_select_same_tag_twice(self): self.assertSelects('p[lang] ~ p', ['lang-en-gb', 'lang-en-us', 'lang-fr']) @@ -2062,8 +2060,8 @@ class TestSoupSelector(TreeTest): self.assertSelects('div x,y, z', ['xid', 'yid', 'zida', 'zidb', 'zidab', 'zidac']) def test_invalid_multiple_select(self): - self.assertRaises(ValueError, self.soup.select, ',x, y') - self.assertRaises(ValueError, self.soup.select, 'x,,y') + self.assertRaises(SyntaxError, self.soup.select, ',x, y') + self.assertRaises(SyntaxError, self.soup.select, 'x,,y') def test_multiple_select_attrs(self): self.assertSelects('p[lang=en], p[lang=en-gb]', ['lang-en', 'lang-en-gb']) @@ -2087,4 +2085,3 @@ class TestSoupSelector(TreeTest): # order. for element in soup.find_all(class_=['c1', 'c2']): assert element in selected - |