mirror of https://github.com/scrapy/scrapy.git
Selector should not receive both response and text
This commit is contained in:
parent
ba6dbad1e0
commit
643dbeffcf
|
|
@ -46,6 +46,10 @@ class Selector(_ParselSelector, object_ref):
|
|||
selectorlist_cls = SelectorList
|
||||
|
||||
def __init__(self, response=None, text=None, type=None, root=None, _root=None, **kwargs):
|
||||
if not(response is None or text is None):
|
||||
raise ValueError('%s.__init__() received both response and text'
|
||||
% self.__class__.__name__)
|
||||
|
||||
st = _st(response, type or self._default_type)
|
||||
|
||||
if _root is not None:
|
||||
|
|
|
|||
|
|
@ -123,6 +123,10 @@ class SelectorTestCase(unittest.TestCase):
|
|||
sel.xpath('//p').extract_unquoted()
|
||||
self.assertSubstring('Use .extract() instead', str(w[-1].message))
|
||||
|
||||
def test_selector_bad_args(self):
|
||||
with self.assertRaisesRegexp(ValueError, 'received both response and text'):
|
||||
Selector(TextResponse(url='http://example.com', body=b''), text=u'')
|
||||
|
||||
|
||||
class DeprecatedXpathSelectorTest(unittest.TestCase):
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue