Reverted change in r590 for inconsistency in the addition operation (doesnt work equally in both ways)

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40598
This commit is contained in:
elpolilla 2009-01-02 13:07:18 +00:00
parent ebd5f465aa
commit 2979521b63
2 changed files with 1 additions and 17 deletions

View File

@ -4,7 +4,7 @@ import unittest
import libxml2
from scrapy.http import Response
from scrapy.xpath.selector import XmlXPathSelector, HtmlXPathSelector, XPathSelectorList
from scrapy.xpath.selector import XmlXPathSelector, HtmlXPathSelector
class XPathTestCase(unittest.TestCase):
@ -220,15 +220,5 @@ class XPathTestCase(unittest.TestCase):
u'\n ',
u'\n pff\n'])
def test_selectorlist_add(self):
'''Adding XPathSelectorLists should return another XPathSelectorList'''
hxs = HtmlXPathSelector(text='<html><body><tag1></tag1><tag2></body></html>')
xlist1 = XPathSelectorList([hxs.x('/'), hxs.x('//tag1')])
xlist2 = XPathSelectorList([hxs.x('/html')])
xlist3 = [1, 2, 3]
self.assertTrue(isinstance(xlist1 + xlist2, XPathSelectorList))
self.assertTrue(isinstance(xlist2 + xlist3, list))
if __name__ == "__main__":
unittest.main()

View File

@ -102,12 +102,6 @@ class XPathSelectorList(list):
def __getslice__(self, i, j):
return XPathSelectorList(list.__getslice__(self, i, j))
def __add__(self, other):
if isinstance(other, XPathSelectorList):
return XPathSelectorList(super(XPathSelectorList, self).__add__(other))
else:
return super(XPathSelectorList, self).__add__(other)
def x(self, xpath):
"""Perform the given XPath query on each XPathSelector of the list and
return a new (flattened) XPathSelectorList of the results"""