Remove six.moves occurrences from tests

This commit is contained in:
Eugenio Lacuesta 2019-11-03 00:01:09 -03:00
parent df00389c16
commit 5ab0f189ce
No known key found for this signature in database
GPG Key ID: DA3EF2D0913E9810
18 changed files with 39 additions and 43 deletions

View File

@ -1,6 +1,10 @@
import sys, time, random, os, json
from six.moves.urllib.parse import urlencode
import json
import os
import random
import sys
import time
from subprocess import Popen, PIPE
from urllib.parse import urlencode
from OpenSSL import SSL
from twisted.web.server import Site, NOT_DONE_YET

View File

@ -3,7 +3,7 @@ Some spiders used for testing and benchmarking
"""
import time
from six.moves.urllib.parse import urlencode
from urllib.parse import urlencode
from scrapy.spiders import Spider
from scrapy.http import Request

View File

@ -140,7 +140,7 @@ class CrawlTestCase(TestCase):
def test_unbounded_response(self):
# Completeness of responses without Content-Length or Transfer-Encoding
# can not be determined, we treat them as valid but flagged as "partial"
from six.moves.urllib.parse import urlencode
from urllib.parse import urlencode
query = urlencode({'raw': '''\
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1

View File

@ -10,8 +10,10 @@ module with the ``runserver`` argument::
python test_engine.py runserver
"""
import sys, os, re
from six.moves.urllib.parse import urlparse
import os
import re
import sys
from urllib.parse import urlparse
from twisted.internet import reactor, defer
from twisted.web import server, static, util

View File

@ -1,11 +1,11 @@
import re
import json
import marshal
import pickle
import tempfile
import unittest
from io import BytesIO
from datetime import datetime
from six.moves import cPickle as pickle
import lxml.etree
import six

View File

@ -2,13 +2,13 @@ import os
import csv
import json
import warnings
from io import BytesIO
import tempfile
import shutil
import string
from io import BytesIO
from unittest import mock
from six.moves.urllib.parse import urljoin, urlparse, quote
from six.moves.urllib.request import pathname2url
from urllib.parse import urljoin, urlparse, quote
from urllib.request import pathname2url
from zope.interface.verify import verifyObject
from twisted.trial import unittest

View File

@ -1,4 +1,4 @@
from six.moves.urllib.parse import urlparse
from urllib.parse import urlparse
from unittest import TestCase
from scrapy.http import Request, Response

View File

@ -3,12 +3,10 @@ import cgi
import unittest
import re
import json
from unittest import mock
from urllib.parse import unquote_to_bytes
import xmlrpc.client as xmlrpclib
import warnings
from six.moves import xmlrpc_client as xmlrpclib
from six.moves.urllib.parse import urlparse, parse_qs, unquote
from unittest import mock
from urllib.parse import parse_qs, unquote, unquote_to_bytes, urlparse
from scrapy.http import Request, FormRequest, XmlRpcRequest, JsonRequest, Headers, HtmlResponse
from scrapy.utils.python import to_bytes, to_unicode

View File

@ -4,9 +4,9 @@ import time
from tempfile import mkdtemp
from shutil import rmtree
from unittest import mock
from six.moves.urllib.parse import urlparse
from six import BytesIO
from urllib.parse import urlparse
from six import BytesIO
from twisted.trial import unittest
from twisted.internet import defer

View File

@ -1,15 +1,15 @@
import json
import os
import time
from six.moves.urllib.parse import urlsplit, urlunsplit
from urllib.parse import urlsplit, urlunsplit
from threading import Thread
from libmproxy import controller, proxy
from netlib import http_auth
from testfixtures import LogCapture
from twisted.internet import defer
from twisted.trial.unittest import TestCase
from scrapy.utils.test import get_crawler
from scrapy.http import Request
from tests.spiders import SimpleSpider, SingleRequestSpider

View File

@ -1,13 +1,12 @@
from unittest import TestCase
from six.moves.urllib.parse import urlparse
from urllib.parse import urlparse
import warnings
from scrapy.http import Response, Request
from scrapy.spiders import Spider
from scrapy.spidermiddlewares.offsite import OffsiteMiddleware
from scrapy.spidermiddlewares.offsite import URLWarning
from scrapy.spidermiddlewares.offsite import OffsiteMiddleware, URLWarning
from scrapy.utils.test import get_crawler
import warnings
class TestOffsiteMiddleware(TestCase):

View File

@ -1,4 +1,4 @@
from six.moves.urllib.parse import urlparse
from urllib.parse import urlparse
from unittest import TestCase
import warnings

View File

@ -1,4 +1,4 @@
from six.moves.urllib.parse import urlparse
from urllib.parse import urlparse
import unittest

View File

@ -192,14 +192,6 @@ class SequenceExcludeTest(unittest.TestCase):
self.assertIn(20, d)
self.assertNotIn(15, d)
def test_six_range(self):
import six.moves
seq = six.moves.range(10**3, 10**6)
d = SequenceExclude(seq)
self.assertIn(10**2, d)
self.assertIn(10**7, d)
self.assertNotIn(10**4, d)
def test_range_step(self):
seq = range(10, 20, 3)
d = SequenceExclude(seq)

View File

@ -5,8 +5,6 @@ from twisted.python.failure import Failure
from scrapy.utils.defer import mustbe_deferred, process_chain, \
process_chain_both, process_parallel, iter_errback
from six.moves import xrange
class MustbeDeferredTest(unittest.TestCase):
def test_success_function(self):
@ -83,7 +81,7 @@ class IterErrbackTest(unittest.TestCase):
def test_iter_errback_good(self):
def itergood():
for x in xrange(10):
for x in range(10):
yield x
errors = []
@ -93,7 +91,7 @@ class IterErrbackTest(unittest.TestCase):
def test_iter_errback_bad(self):
def iterbad():
for x in xrange(10):
for x in range(10):
if x == 5:
a = 1/0
yield x

View File

@ -1,9 +1,10 @@
import unittest
from six.moves.urllib.parse import urlparse
from urllib.parse import urlparse
from scrapy.http import Request
from scrapy.utils.httpobj import urlparse_cached
class HttpobjUtilsTest(unittest.TestCase):
def test_urlparse_cached(self):

View File

@ -1,12 +1,13 @@
import os
import unittest
from six.moves.urllib.parse import urlparse
from urllib.parse import urlparse
from scrapy.http import Response, TextResponse, HtmlResponse
from scrapy.utils.python import to_bytes
from scrapy.utils.response import (response_httprepr, open_in_browser,
get_meta_refresh, get_base_url, response_status_message)
__doctests__ = ['scrapy.utils.response']

View File

@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
import unittest
from urllib.parse import urlparse
import six
from six.moves.urllib.parse import urlparse
from scrapy.spiders import Spider
from scrapy.utils.url import (url_is_from_any_domain, url_is_from_spider,
add_http_if_no_scheme, guess_scheme,
parse_url, strip_url)
__doctests__ = ['scrapy.utils.url']