Scrapy, a fast high-level web crawling & scraping framework for Python.
Ignore ScrapyDeprecationWarning warnings properly.
Berker Peksag8a48d9c6a872
diff --git a/scrapy/linkextractors/sgml.py b/scrapy/linkextractors/sgml.pyindex bae4ad5c0..a9b8fe9de 100644--- a/scrapy/linkextractors/sgml.py+++ b/scrapy/linkextractors/sgml.py@@ -111,7 +111,8 @@ class SgmlLinkExtractor(FilteringLinkExtractor):tag_func = lambda x: x in tagsattr_func = lambda x: x in attrs- with warnings.catch_warnings(record=True):+ with warnings.catch_warnings():+ warnings.simplefilter('ignore', ScrapyDeprecationWarning)lx = BaseSgmlLinkExtractor(tag=tag_func, attr=attr_func,unique=unique, process_value=process_value)diff --git a/tests/test_selector.py b/tests/test_selector.pyindex 09dbe6086..ad6a0e21c 100644--- a/tests/test_selector.py+++ b/tests/test_selector.py@@ -490,21 +490,24 @@ class DeprecatedXpathSelectorTest(unittest.TestCase):self.assertTrue(isinstance(usel, XPathSelector))def test_xpathselector(self):- with warnings.catch_warnings(record=True):+ with warnings.catch_warnings():+ warnings.simplefilter('ignore', ScrapyDeprecationWarning)hs = XPathSelector(text=self.text)self.assertEqual(hs.select("//div").extract(),[u'<div><img src="a.jpg"><p>Hello</p></div>'])self.assertRaises(RuntimeError, hs.css, 'div')def test_htmlxpathselector(self):- with warnings.catch_warnings(record=True):+ with warnings.catch_warnings():+ warnings.simplefilter('ignore', ScrapyDeprecationWarning)hs = HtmlXPathSelector(text=self.text)self.assertEqual(hs.select("//div").extract(),[u'<div><img src="a.jpg"><p>Hello</p></div>'])self.assertRaises(RuntimeError, hs.css, 'div')def test_xmlxpathselector(self):- with warnings.catch_warnings(record=True):+ with warnings.catch_warnings():+ warnings.simplefilter('ignore', ScrapyDeprecationWarning)xs = XmlXPathSelector(text=self.text)self.assertEqual(xs.select("//div").extract(),[u'<div><img src="a.jpg"><p>Hello</p></img></div>'])diff --git a/tests/test_utils_deprecate.py b/tests/test_utils_deprecate.pyindex 41b8100d7..3e7236fb1 100644--- a/tests/test_utils_deprecate.py+++ b/tests/test_utils_deprecate.py@@ -3,6 +3,7 @@ from __future__ import absolute_importimport inspectimport unittestimport warnings+from scrapy.exceptions import ScrapyDeprecationWarningfrom scrapy.utils.deprecate import create_deprecated_class, update_classpathfrom tests import mock@@ -109,7 +110,8 @@ class WarnWhenSubclassedTest(unittest.TestCase):warn_category=MyWarning)# ignore subclassing warnings- with warnings.catch_warnings(record=True):+ with warnings.catch_warnings():+ warnings.simplefilter('ignore', ScrapyDeprecationWarning)class UserClass(Deprecated):pass@@ -138,7 +140,8 @@ class WarnWhenSubclassedTest(unittest.TestCase):self.assertIn("tests.test_utils_deprecate.Deprecated", msg)def test_issubclass(self):- with warnings.catch_warnings(record=True):+ with warnings.catch_warnings():+ warnings.simplefilter('ignore', ScrapyDeprecationWarning)DeprecatedName = create_deprecated_class('DeprecatedName', NewName)class UpdatedUserClass1(NewName):@@ -173,7 +176,8 @@ class WarnWhenSubclassedTest(unittest.TestCase):self.assertRaises(TypeError, issubclass, object(), DeprecatedName)def test_isinstance(self):- with warnings.catch_warnings(record=True):+ with warnings.catch_warnings():+ warnings.simplefilter('ignore', ScrapyDeprecationWarning)DeprecatedName = create_deprecated_class('DeprecatedName', NewName)class UpdatedUserClass2(NewName):@@ -206,7 +210,8 @@ class WarnWhenSubclassedTest(unittest.TestCase):assert not isinstance(OldStyleClass(), DeprecatedName)def test_clsdict(self):- with warnings.catch_warnings(record=True):+ with warnings.catch_warnings():+ warnings.simplefilter('ignore', ScrapyDeprecationWarning)Deprecated = create_deprecated_class('Deprecated', NewName, {'foo': 'bar'})self.assertEqual(Deprecated.foo, 'bar')@@ -264,7 +269,8 @@ class UpdateClassPathTest(unittest.TestCase):self.assertIn("scrapy.extensions.debug.Debug", str(w[0].message))def test_sorted_replacement(self):- with warnings.catch_warnings(record=True):+ with warnings.catch_warnings():+ warnings.simplefilter('ignore', ScrapyDeprecationWarning)output = update_classpath('scrapy.contrib.pipeline.Pipeline')self.assertEqual(output, 'scrapy.pipelines.Pipeline')