Beispiel #1
0
 def test_tokenizer(self):
     tokens = [
         _unicode(item) for item in tokenize(
             u(r'E\ é > f [a~="y\"x"]:nth(/* fu /]* */-3.7)'))
     ]
     assert tokens == [
         u("<IDENT 'E é' at 0>"),
         "<S ' ' at 4>",
         "<DELIM '>' at 5>",
         "<S ' ' at 6>",
         # the no-break space is not whitespace in CSS
         u("<IDENT 'f ' at 7>"),  # f\xa0
         "<DELIM '[' at 9>",
         "<IDENT 'a' at 10>",
         "<DELIM '~' at 11>",
         "<DELIM '=' at 12>",
         "<STRING 'y\"x' at 13>",
         "<DELIM ']' at 19>",
         "<DELIM ':' at 20>",
         "<IDENT 'nth' at 21>",
         "<DELIM '(' at 24>",
         "<NUMBER '-3.7' at 37>",
         "<DELIM ')' at 41>",
         "<EOF at 42>",
     ]
Beispiel #2
0
 def test_tokenizer(self):
     tokens = [
         _unicode(item) for item in tokenize(
             u(r'E\ é > f [a~="y\"x"]:nth(/* fu /]* */-3.7)'))]
     assert tokens == [
         u("<IDENT 'E é' at 0>"),
         "<S ' ' at 4>",
         "<DELIM '>' at 5>",
         "<S ' ' at 6>",
         # the no-break space is not whitespace in CSS
         u("<IDENT 'f ' at 7>"),  # f\xa0
         "<DELIM '[' at 9>",
         "<IDENT 'a' at 10>",
         "<DELIM '~' at 11>",
         "<DELIM '=' at 12>",
         "<STRING 'y\"x' at 13>",
         "<DELIM ']' at 19>",
         "<DELIM ':' at 20>",
         "<IDENT 'nth' at 21>",
         "<DELIM '(' at 24>",
         "<NUMBER '-3.7' at 37>",
         "<DELIM ')' at 41>",
         "<EOF at 42>",
     ]
Beispiel #3
0
 def xpath(css):
     return _unicode(GenericTranslator().css_to_xpath(css, prefix=''))
Beispiel #4
0
 def xpath(css):
     return _unicode(GenericTranslator().css_to_xpath(css, prefix=''))