Scrapy, a fast high-level web crawling & scraping framework for Python.
remove deprecated module lxmldocument
Elias Dorneles94c3a345b75d
diff --git a/scrapy/selector/lxmldocument.py b/scrapy/selector/lxmldocument.pydeleted file mode 100644index 817349b58..000000000--- a/scrapy/selector/lxmldocument.py+++ /dev/null@@ -1,31 +0,0 @@-"""-This module contains a simple class (LxmlDocument) which provides cache and-garbage collection to lxml element tree documents.-"""--import weakref-from lxml import etree-from scrapy.utils.trackref import object_ref---def _factory(response, parser_cls):- url = response.url- body = response.body_as_unicode().strip().encode('utf8') or '<html/>'- parser = parser_cls(recover=True, encoding='utf8')- return etree.fromstring(body, parser=parser, base_url=url)---class LxmlDocument(object_ref):-- cache = weakref.WeakKeyDictionary()- __slots__ = ['__weakref__']-- def __new__(cls, response, parser=etree.HTMLParser):- cache = cls.cache.setdefault(response, {})- if parser not in cache:- obj = object_ref.__new__(cls)- cache[parser] = _factory(response, parser)- return cache[parser]-- def __str__(self):- return "<LxmlDocument %s>" % self.root.tagdiff --git a/tests/py3-ignores.txt b/tests/py3-ignores.txtindex 9be3a99a8..8f5c0de48 100644--- a/tests/py3-ignores.txt+++ b/tests/py3-ignores.txt@@ -26,7 +26,6 @@ tests/test_pipeline_files.pytests/test_pipeline_images.pytests/test_proxy_connect.pytests/test_selector_csstranslator.py-tests/test_selector_lxmldocument.pytests/test_selector.pytests/test_spidermiddleware_depth.pytests/test_spidermiddleware_httperror.pydiff --git a/tests/test_selector_lxmldocument.py b/tests/test_selector_lxmldocument.pydeleted file mode 100644index 090cc21bc..000000000--- a/tests/test_selector_lxmldocument.py+++ /dev/null@@ -1,26 +0,0 @@-import unittest-from scrapy.selector.lxmldocument import LxmlDocument-from scrapy.http import TextResponse, HtmlResponse---class LxmlDocumentTest(unittest.TestCase):-- def test_caching(self):- r1 = HtmlResponse('http://www.example.com', body=b'<html><head></head><body></body></html>')- r2 = r1.copy()-- doc1 = LxmlDocument(r1)- doc2 = LxmlDocument(r1)- doc3 = LxmlDocument(r2)-- # make sure it's cached- assert doc1 is doc2- assert doc1 is not doc3-- def test_null_char(self):- # make sure bodies with null char ('\x00') don't raise a TypeError exception- body = b'test problematic \x00 body'- response = TextResponse('http://example.com/catalog/product/blabla-123',- headers={'Content-Type': 'text/plain; charset=utf-8'},- body=body)- LxmlDocument(response)