[Python-modules-commits] [python-cssselect] 03/06: Improve selector_to_xpath tests on pseudo-elements
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Oct 11 23:20:10 UTC 2014
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to reference refs/remotes/upstream/master
in repository python-cssselect.
commit 38e2edb4a2bebbce1972b24d9cabaedfa14459b2
Author: Daniel Graña <dangra at gmail.com>
Date: Thu Oct 17 15:21:59 2013 -0200
Improve selector_to_xpath tests on pseudo-elements
---
cssselect/tests.py | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/cssselect/tests.py b/cssselect/tests.py
index 8b69740..a1fdc9e 100755
--- a/cssselect/tests.py
+++ b/cssselect/tests.py
@@ -196,6 +196,21 @@ class TestCssselect(unittest.TestCase):
('Element[bar]', None),
('Element[baz]', 'after')]
+ # Special cases for CSS 2.1 pseudo-elements are ignored by default
+ for pseudo in ('after', 'before', 'first-line', 'first-letter'):
+ selector, = parse('e:%s' % pseudo)
+ assert selector.pseudo_element == pseudo
+ assert GenericTranslator().selector_to_xpath(selector, prefix='') == "e"
+
+ # Pseudo Elements are ignored by default, but if allowed they are not
+ # supported by GenericTranslator
+ tr = GenericTranslator()
+ selector, = parse('e::foo')
+ assert selector.pseudo_element == 'foo'
+ assert tr.selector_to_xpath(selector, prefix='') == "e"
+ self.assertRaises(ExpressionError, tr.selector_to_xpath, selector,
+ translate_pseudo_elements=True)
+
def test_specificity(self):
def specificity(css):
selectors = parse(css)
@@ -380,11 +395,6 @@ class TestCssselect(unittest.TestCase):
assert xpath('div#container p') == (
"div[@id = 'container']/descendant-or-self::*/p")
- selector, = parse('e:after')
- assert selector.pseudo_element == 'after'
- # Pseudo-element is ignored:
- assert GenericTranslator().selector_to_xpath(selector, prefix='') == "e"
-
# Invalid characters in XPath element names
assert xpath(r'di\a0 v') == (
u("*[name() = 'di v']")) # di\xa0v
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-cssselect.git
More information about the Python-modules-commits
mailing list