Prevent even more DeprecationWarnings

This commit is contained in:
Eugenio Lacuesta 2019-07-13 22:14:47 -03:00
parent 40086dabb8
commit eced544d64
No known key found for this signature in database
GPG Key ID: DA3EF2D0913E9810
3 changed files with 30 additions and 20 deletions

View File

@ -4,16 +4,22 @@ Scrapy Item
See documentation in docs/topics/item.rst
"""
from pprint import pformat
from collections import MutableMapping
from copy import deepcopy
from abc import ABCMeta
from pprint import pformat
from copy import deepcopy
import collections
import six
from scrapy.utils.trackref import object_ref
if six.PY3:
MutableMapping = collections.abc.MutableMapping
else:
MutableMapping = collections.MutableMapping
class BaseItem(object_ref):
"""Base class for all scraped items."""
pass

View File

@ -6,13 +6,20 @@ This module must not depend on any module outside the Standard Library.
"""
import copy
import six
import collections
import warnings
from collections import OrderedDict, Mapping
import six
from scrapy.exceptions import ScrapyDeprecationWarning
if six.PY3:
Mapping = collections.abc.Mapping
else:
Mapping = collections.Mapping
class MultiValueDictKeyError(KeyError):
def __init__(self, *args, **kwargs):
warnings.warn(
@ -289,7 +296,7 @@ class MergeDict(object):
return self.__copy__()
class LocalCache(OrderedDict):
class LocalCache(collections.OrderedDict):
"""Dictionary with a finite number of keys.
Older items expires first.

View File

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import re
from twisted.internet import reactor, error
from twisted.internet.defer import Deferred, DeferredList, maybeDeferred
from twisted.python import failure
@ -31,18 +30,16 @@ class RobotsTxtMiddlewareTest(unittest.TestCase):
def _get_successful_crawler(self):
crawler = self.crawler
crawler.settings.set('ROBOTSTXT_OBEY', True)
ROBOTS = re.sub(b'^\s+(?m)', b'', u'''
User-Agent: *
Disallow: /admin/
Disallow: /static/
# taken from https://en.wikipedia.org/robots.txt
Disallow: /wiki/K%C3%A4ytt%C3%A4j%C3%A4:
Disallow: /wiki/Käyttäjä:
User-Agent: UnicödeBöt
Disallow: /some/randome/page.html
'''.encode('utf-8'))
ROBOTS = u"""
User-Agent: *
Disallow: /admin/
Disallow: /static/
# taken from https://en.wikipedia.org/robots.txt
Disallow: /wiki/K%C3%A4ytt%C3%A4j%C3%A4:
Disallow: /wiki/Käyttäjä:
User-Agent: UnicödeBöt
Disallow: /some/randome/page.html
""".encode('utf-8')
response = TextResponse('http://site.local/robots.txt', body=ROBOTS)
def return_response(request, spider):
deferred = Deferred()