提交 41588397 编写于 作者: P Paul Tremberth

Merge pull request #1765 from scrapy/add-deprecation-for-pydispatch

[MRG+1] Add fallback and deprecation warning for pydispatch (fixes #1762)
......@@ -124,6 +124,9 @@ Deprecations and Removals
+ ``scrapy.utils.datatypes.MultiValueDict``
+ ``scrapy.utils.datatypes.SiteNode``
- The previously bundled ``scrapy.xlib.pydispatch`` library was deprecated and
replaced by `pydispatcher <https://pypi.python.org/pypi/PyDispatcher>`_.
Relocations
~~~~~~~~~~~
......
from __future__ import absolute_import
import warnings
from scrapy.exceptions import ScrapyDeprecationWarning
from pydispatch import (
dispatcher,
errors,
robust,
robustapply,
saferef,
)
warnings.warn("Importing from scrapy.xlib.pydispatch is deprecated and will"
" no longer be supported in future Scrapy versions."
" If you just want to connect signals use the from_crawler class method,"
" otherwise import pydispatch directly if needed."
" See: https://github.com/scrapy/scrapy/issues/1762",
ScrapyDeprecationWarning, stacklevel=2)
import unittest
import warnings
from six.moves import reload_module
class DeprecatedPydispatchTest(unittest.TestCase):
def test_import_xlib_pydispatch_show_warning(self):
with warnings.catch_warnings(record=True) as w:
from scrapy.xlib import pydispatch
reload_module(pydispatch)
self.assertIn('Importing from scrapy.xlib.pydispatch is deprecated',
str(w[0].message))
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册