mirror of https://github.com/scrapy/scrapy.git
Add missing priority and errback arguments to Request.replace method signature
This commit is contained in:
parent
60961e5499
commit
2322322ee6
|
|
@ -96,8 +96,9 @@ class Request(object_ref):
|
|||
"""Return a copy of this Request"""
|
||||
return self.replace()
|
||||
|
||||
def replace(self, url=None, callback=None, method=None, headers=None, body=None,
|
||||
cookies=None, meta=None, encoding=None, dont_filter=None):
|
||||
def replace(self, url=None, callback=None, method=None, headers=None, body=None, \
|
||||
cookies=None, meta=None, encoding=None, priority=None, \
|
||||
dont_filter=None, errback=None):
|
||||
"""Create a new Request with the same attributes except for those
|
||||
given new values.
|
||||
"""
|
||||
|
|
@ -109,4 +110,6 @@ class Request(object_ref):
|
|||
cookies=self.cookies if cookies is None else cookies,
|
||||
meta=self.meta if meta is None else meta,
|
||||
encoding=self.encoding if encoding is None else encoding,
|
||||
dont_filter=self.dont_filter if dont_filter is None else dont_filter)
|
||||
priority=self.priority if priority is None else priority,
|
||||
dont_filter=self.dont_filter if dont_filter is None else dont_filter,
|
||||
errback=errback)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import cgi
|
|||
import weakref
|
||||
import unittest
|
||||
import xmlrpclib
|
||||
from inspect import getargspec
|
||||
from cStringIO import StringIO
|
||||
from urlparse import urlparse
|
||||
|
||||
|
|
@ -170,6 +171,13 @@ class RequestTest(unittest.TestCase):
|
|||
self.assertEqual(r4.meta, {})
|
||||
assert r4.dont_filter is False
|
||||
|
||||
# __init__ and replace() signatures must be equal unles *args,**kwargs is used
|
||||
i_args, i_varargs, i_varkwargs, _ = getargspec(self.request_class.__init__)
|
||||
self.assertFalse(bool(i_varargs) ^ bool(i_varkwargs))
|
||||
if not i_varargs:
|
||||
r_args, _, _, _ = getargspec(self.request_class.replace)
|
||||
self.assertEqual(i_args, r_args)
|
||||
|
||||
def test_weakref_slots(self):
|
||||
"""Check that classes are using slots and are weak-referenceable"""
|
||||
x = self.request_class('http://www.example.com')
|
||||
|
|
|
|||
Loading…
Reference in New Issue