Permalink
Browse files

Remove dead code.

  • Loading branch information...
SimonSapin committed Apr 20, 2012
1 parent ab99922 commit b6730b5ab440a06fe8b4d4a897b7988f84760590
Showing with 12 additions and 15 deletions.
  1. +7 −13 cssselect/parser.py
  2. +5 −2 cssselect/tests.py
View
@@ -589,18 +589,15 @@ def tokenize_escaped_string(s, pos):
def tokenize_symbol(s, pos):
start = pos
match = _illegal_symbol.search(s, pos=pos)
- if not match:
- # Goes to end of s
- return s[start:], len(s)
- if match.start() == pos:
- raise SelectorSyntaxError(
- "Unexpected symbol: %r" % s[pos])
- if not match:
- result = s[start:]
- pos = len(s)
- else:
+ if match:
+ if match.start() == pos:
+ raise SelectorSyntaxError(
+ "Unexpected symbol: %r" % s[pos])
result = s[start:match.start()]
pos = match.start()
+ else:
+ result = s[start:]
+ pos = len(s)
try:
result = result.encode('ASCII', 'backslashreplace').decode('unicode_escape')
except UnicodeDecodeError:
@@ -636,9 +633,6 @@ def next(self):
except StopIteration:
return None
- def __iter__(self):
- return iter(self.next, None)
-
def peek(self):
if not self._peeking:
try:
View
@@ -281,6 +281,11 @@ def get_error(css):
assert get_error(':lang(fr') == (
"Expected ')', got 'None' at [Token(':', 0), Symbol('lang', 1), "
"Token('(', 5), Symbol('fr', 6)] -> None")
+ assert get_error(':contains("foo') == (
+ "Expected closing \" for string in: 'foo' at "
+ "[Token(':', 0), Symbol('contains', 1), Token('(', 9)] -> None")
+ assert get_error('foo!') == (
+ "Unexpected symbol: '!' at [Symbol('foo', 0)] -> None")
# Mis-placed pseudo-elements
assert get_error('a:before:empty') == (
@@ -300,7 +305,6 @@ def get_error(css):
"Token('(', 4), Token(':', 5), Symbol('not', 6), Token('(', 9)]"
" -> Symbol('a', 10)")
-
def test_translation(self):
def xpath(css):
return str(GenericTranslator().css_to_xpath(css, prefix=''))
@@ -383,7 +387,6 @@ def xpath(css):
self.assertRaises(ExpressionError, xpath, ':lang(fr)')
self.assertRaises(ExpressionError, xpath, ':nth-child(n-)')
-
def test_unicode(self):
if sys.version_info[0] >= 3:
css = '.a\xc1b'

0 comments on commit b6730b5

Please sign in to comment.