mirror of https://github.com/scrapy/scrapy.git
docs: use "constructor" for from_settings() & rom_crawler() factory methods
Issue #4086
This commit is contained in:
parent
d21e1034f0
commit
7a84a4bdba
|
|
@ -123,14 +123,14 @@ def rel_has_nofollow(rel):
|
|||
|
||||
def create_instance(objcls, settings, crawler, *args, **kwargs):
|
||||
"""Construct a class instance using its ``from_crawler`` or
|
||||
``from_settings`` ``__init__`` methods, if available.
|
||||
``from_settings`` constructors, if available.
|
||||
|
||||
At least one of ``settings`` and ``crawler`` needs to be different from
|
||||
``None``. If ``settings `` is ``None``, ``crawler.settings`` will be used.
|
||||
If ``crawler`` is ``None``, only the ``from_settings`` ``__init__`` method will be
|
||||
If ``crawler`` is ``None``, only the ``from_settings`` constructor will be
|
||||
tried.
|
||||
|
||||
``*args`` and ``**kwargs`` are forwarded to the ``__init__`` methods.
|
||||
``*args`` and ``**kwargs`` are forwarded to the constructors.
|
||||
|
||||
Raises ``ValueError`` if both ``settings`` and ``crawler`` are ``None``.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -109,11 +109,11 @@ class UtilsMiscTestCase(unittest.TestCase):
|
|||
else:
|
||||
mock.assert_called_once_with(*args, **kwargs)
|
||||
|
||||
# Check usage of correct __init__ method using four mocks:
|
||||
# 1. with no alternative __init__ methods
|
||||
# 2. with from_settings() __init__ method
|
||||
# 3. with from_crawler() __init__ method
|
||||
# 4. with from_settings() and from_crawler() __init__ method
|
||||
# Check usage of correct constructor using four mocks:
|
||||
# 1. with no alternative constructors
|
||||
# 2. with from_settings() constructor
|
||||
# 3. with from_crawler() constructor
|
||||
# 4. with from_settings() and from_crawler() constructor
|
||||
spec_sets = ([], ['from_settings'], ['from_crawler'],
|
||||
['from_settings', 'from_crawler'])
|
||||
for specs in spec_sets:
|
||||
|
|
|
|||
Loading…
Reference in New Issue