Scrapy, a fast high-level web crawling & scraping framework for Python.
Remove backslash (tests)
Eugenio Lacuesta9aea1f096171
diff --git a/tests/test_downloadermiddleware_httpcompression.py b/tests/test_downloadermiddleware_httpcompression.pyindex 87304d76c..a806f55ce 100644--- a/tests/test_downloadermiddleware_httpcompression.py+++ b/tests/test_downloadermiddleware_httpcompression.py@@ -5,8 +5,7 @@ from gzip import GzipFilefrom scrapy.spiders import Spiderfrom scrapy.http import Response, Request, HtmlResponse-from scrapy.downloadermiddlewares.httpcompression import HttpCompressionMiddleware, \- ACCEPTED_ENCODINGS+from scrapy.downloadermiddlewares.httpcompression import HttpCompressionMiddleware, ACCEPTED_ENCODINGSfrom scrapy.responsetypes import responsetypesfrom scrapy.utils.gz import gunzipfrom tests import tests_datadirdiff --git a/tests/test_downloadermiddleware_redirect.py b/tests/test_downloadermiddleware_redirect.pyindex c46b1bb87..919dbed23 100644--- a/tests/test_downloadermiddleware_redirect.py+++ b/tests/test_downloadermiddleware_redirect.py@@ -77,12 +77,9 @@ class RedirectMiddlewareTest(unittest.TestCase):assert isinstance(req2, Request)self.assertEqual(req2.url, url2)self.assertEqual(req2.method, 'GET')- assert 'Content-Type' not in req2.headers, \- "Content-Type header must not be present in redirected request"- assert 'Content-Length' not in req2.headers, \- "Content-Length header must not be present in redirected request"- assert not req2.body, \- "Redirected body must be empty, not '%s'" % req2.body+ assert 'Content-Type' not in req2.headers, "Content-Type header must not be present in redirected request"+ assert 'Content-Length' not in req2.headers, "Content-Length header must not be present in redirected request"+ assert not req2.body, "Redirected body must be empty, not '%s'" % req2.body# response without Location header but with status code is 3XX should be ignoreddel rsp.headers['Location']@@ -244,12 +241,9 @@ class MetaRefreshMiddlewareTest(unittest.TestCase):assert isinstance(req2, Request)self.assertEqual(req2.url, 'http://example.org/newpage')self.assertEqual(req2.method, 'GET')- assert 'Content-Type' not in req2.headers, \- "Content-Type header must not be present in redirected request"- assert 'Content-Length' not in req2.headers, \- "Content-Length header must not be present in redirected request"- assert not req2.body, \- "Redirected body must be empty, not '%s'" % req2.body+ assert 'Content-Type' not in req2.headers, "Content-Type header must not be present in redirected request"+ assert 'Content-Length' not in req2.headers, "Content-Length header must not be present in redirected request"+ assert not req2.body, "Redirected body must be empty, not '%s'" % req2.bodydef test_max_redirect_times(self):self.mw.max_redirect_times = 1diff --git a/tests/test_selector.py b/tests/test_selector.pyindex bcf653444..00e663c11 100644--- a/tests/test_selector.py+++ b/tests/test_selector.py@@ -88,8 +88,7 @@ class SelectorTestCase(unittest.TestCase):"""Check that classes are using slots and are weak-referenceable"""x = Selector(text='')weakref.ref(x)- assert not hasattr(x, '__dict__'), "%s does not use __slots__" % \- x.__class__.__name__+ assert not hasattr(x, '__dict__'), "%s does not use __slots__" % x.__class__.__name__def test_selector_bad_args(self):with self.assertRaisesRegex(ValueError, 'received both response and text'):diff --git a/tests/test_settings/__init__.py b/tests/test_settings/__init__.pyindex 2da6aa4b5..6e56a28f5 100644--- a/tests/test_settings/__init__.py+++ b/tests/test_settings/__init__.py@@ -86,8 +86,7 @@ class BaseSettingsTest(unittest.TestCase):def test_set_calls_settings_attributes_methods_on_update(self):attr = SettingsAttribute('value', 10)- with mock.patch.object(attr, '__setattr__') as mock_setattr, \- mock.patch.object(attr, 'set') as mock_set:+ with mock.patch.object(attr, '__setattr__') as mock_setattr, mock.patch.object(attr, 'set') as mock_set:self.settings.attributes = {'TEST_OPTION': attr}diff --git a/tests/test_spider.py b/tests/test_spider.pyindex 805d70459..bd9238810 100644--- a/tests/test_spider.py+++ b/tests/test_spider.py@@ -11,8 +11,14 @@ from scrapy import signalsfrom scrapy.settings import Settingsfrom scrapy.http import Request, Response, TextResponse, XmlResponse, HtmlResponsefrom scrapy.spiders.init import InitSpider-from scrapy.spiders import Spider, CrawlSpider, Rule, XMLFeedSpider, \- CSVFeedSpider, SitemapSpider+from scrapy.spiders import (+ CSVFeedSpider,+ CrawlSpider,+ Rule,+ SitemapSpider,+ Spider,+ XMLFeedSpider,+)from scrapy.linkextractors import LinkExtractorfrom scrapy.exceptions import ScrapyDeprecationWarningfrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_spidermiddleware_referer.py b/tests/test_spidermiddleware_referer.pyindex 067118cf0..5141f47af 100644--- a/tests/test_spidermiddleware_referer.py+++ b/tests/test_spidermiddleware_referer.py@@ -6,16 +6,28 @@ from scrapy.http import Response, Requestfrom scrapy.settings import Settingsfrom scrapy.spiders import Spiderfrom scrapy.downloadermiddlewares.redirect import RedirectMiddleware-from scrapy.spidermiddlewares.referer import RefererMiddleware, \- POLICY_NO_REFERRER, POLICY_NO_REFERRER_WHEN_DOWNGRADE, \- POLICY_SAME_ORIGIN, POLICY_ORIGIN, POLICY_ORIGIN_WHEN_CROSS_ORIGIN, \- POLICY_SCRAPY_DEFAULT, POLICY_UNSAFE_URL, \- POLICY_STRICT_ORIGIN, POLICY_STRICT_ORIGIN_WHEN_CROSS_ORIGIN, \- DefaultReferrerPolicy, \- NoReferrerPolicy, NoReferrerWhenDowngradePolicy, \- OriginWhenCrossOriginPolicy, OriginPolicy, \- StrictOriginWhenCrossOriginPolicy, StrictOriginPolicy, \- SameOriginPolicy, UnsafeUrlPolicy, ReferrerPolicy+from scrapy.spidermiddlewares.referer import (+ DefaultReferrerPolicy,+ NoReferrerPolicy,+ NoReferrerWhenDowngradePolicy,+ OriginPolicy,+ OriginWhenCrossOriginPolicy,+ POLICY_NO_REFERRER,+ POLICY_NO_REFERRER_WHEN_DOWNGRADE,+ POLICY_ORIGIN,+ POLICY_ORIGIN_WHEN_CROSS_ORIGIN,+ POLICY_SAME_ORIGIN,+ POLICY_SCRAPY_DEFAULT,+ POLICY_STRICT_ORIGIN,+ POLICY_STRICT_ORIGIN_WHEN_CROSS_ORIGIN,+ POLICY_UNSAFE_URL,+ RefererMiddleware,+ ReferrerPolicy,+ SameOriginPolicy,+ StrictOriginPolicy,+ StrictOriginWhenCrossOriginPolicy,+ UnsafeUrlPolicy,+)class TestRefererMiddleware(TestCase):diff --git a/tests/test_utils_curl.py b/tests/test_utils_curl.pyindex 299a51efe..6b05c8771 100644--- a/tests/test_utils_curl.py+++ b/tests/test_utils_curl.py@@ -29,8 +29,7 @@ class CurlToRequestKwargsTest(unittest.TestCase):self._test_command(curl_command, expected_result)def test_get_basic_auth(self):- curl_command = 'curl "https://api.test.com/" -u ' \- '"some_username:some_password"'+ curl_command = 'curl "https://api.test.com/" -u "some_username:some_password"'expected_result = {"method": "GET","url": "https://api.test.com/",@@ -212,8 +211,7 @@ class CurlToRequestKwargsTest(unittest.TestCase):with warnings.catch_warnings(): # avoid warning when executing testswarnings.simplefilter('ignore')curl_command = 'curl --bar --baz http://www.example.com'- expected_result = \- {"method": "GET", "url": "http://www.example.com"}+ expected_result = {"method": "GET", "url": "http://www.example.com"}self.assertEqual(curl_to_request_kwargs(curl_command), expected_result)# case 2: ignore_unknown_options=False (raise exception):diff --git a/tests/test_utils_defer.py b/tests/test_utils_defer.pyindex 2d4b88121..8c84331b9 100644--- a/tests/test_utils_defer.py+++ b/tests/test_utils_defer.py@@ -2,8 +2,13 @@ from twisted.trial import unittestfrom twisted.internet import reactor, deferfrom twisted.python.failure import Failure-from scrapy.utils.defer import mustbe_deferred, process_chain, \- process_chain_both, process_parallel, iter_errback+from scrapy.utils.defer import (+ iter_errback,+ mustbe_deferred,+ process_chain,+ process_chain_both,+ process_parallel,+)class MustbeDeferredTest(unittest.TestCase):diff --git a/tests/test_utils_iterators.py b/tests/test_utils_iterators.pyindex 8344c6701..3ebe3ac24 100644--- a/tests/test_utils_iterators.py+++ b/tests/test_utils_iterators.py@@ -15,18 +15,20 @@ class XmliterTestCase(unittest.TestCase):xmliter = staticmethod(xmliter)def test_xmliter(self):- body = b"""<?xml version="1.0" encoding="UTF-8"?>\+ body = b"""+ <?xml version="1.0" encoding="UTF-8"?><products xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"- xsi:noNamespaceSchemaLocation="someschmea.xsd">\- <product id="001">\- <type>Type 1</type>\- <name>Name 1</name>\- </product>\- <product id="002">\- <type>Type 2</type>\- <name>Name 2</name>\- </product>\- </products>"""+ xsi:noNamespaceSchemaLocation="someschmea.xsd">+ <product id="001">+ <type>Type 1</type>+ <name>Name 1</name>+ </product>+ <product id="002">+ <type>Type 2</type>+ <name>Name 2</name>+ </product>+ </products>+ """response = XmlResponse(url="http://example.com", body=body)attrs = []@@ -115,7 +117,7 @@ class XmliterTestCase(unittest.TestCase):[[u'one'], [u'two']])def test_xmliter_namespaces(self):- body = b"""\+ body = b"""<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:g="http://base.google.com/ns/1.0"><channel>@@ -185,7 +187,7 @@ class LxmlXmliterTestCase(XmliterTestCase):xmliter = staticmethod(xmliter_lxml)def test_xmliter_iterate_namespace(self):- body = b"""\+ body = b"""<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns="http://base.google.com/ns/1.0"><channel>@@ -214,7 +216,7 @@ class LxmlXmliterTestCase(XmliterTestCase):self.assertEqual(node.xpath('text()').getall(), ['http://www.mydummycompany.com/images/item2.jpg'])def test_xmliter_namespaces_prefix(self):- body = b"""\+ body = b"""<?xml version="1.0" encoding="UTF-8"?><root><h:table xmlns:h="http://www.w3.org/TR/html4/">diff --git a/tests/test_utils_request.py b/tests/test_utils_request.pyindex 4cd4b7010..7e0049b1d 100644--- a/tests/test_utils_request.py+++ b/tests/test_utils_request.py@@ -1,7 +1,11 @@import unittestfrom scrapy.http import Request-from scrapy.utils.request import request_fingerprint, _fingerprint_cache, \- request_authenticate, request_httprepr+from scrapy.utils.request import (+ _fingerprint_cache,+ request_authenticate,+ request_fingerprint,+ request_httprepr,+)class UtilsRequestTest(unittest.TestCase):diff --git a/tests/test_utils_response.py b/tests/test_utils_response.pyindex 6ebf290c0..d6f4c0bb5 100644--- a/tests/test_utils_response.py+++ b/tests/test_utils_response.py@@ -37,8 +37,7 @@ class ResponseUtilsTest(unittest.TestCase):self.assertIn(b'<base href="' + to_bytes(url) + b'">', bbody)return Trueresponse = HtmlResponse(url, body=body)- assert open_in_browser(response, _openfunc=browser_open), \- "Browser not called"+ assert open_in_browser(response, _openfunc=browser_open), "Browser not called"resp = Response(url, body=body)self.assertRaises(TypeError, open_in_browser, resp, debug=True)diff --git a/tests/test_utils_sitemap.py b/tests/test_utils_sitemap.pyindex bfbf9abb3..23eb261b7 100644--- a/tests/test_utils_sitemap.py+++ b/tests/test_utils_sitemap.py@@ -156,8 +156,7 @@ Disallow: /forum/active/def test_sitemap_blanklines(self):"""Assert we can deal with starting blank lines before <xml> tag"""- s = Sitemap(b"""\-+ s = Sitemap(b"""<?xml version="1.0" encoding="UTF-8"?><sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">diff --git a/tests/test_utils_url.py b/tests/test_utils_url.pyindex 09a6d6c70..a194a0998 100644--- a/tests/test_utils_url.py+++ b/tests/test_utils_url.py@@ -207,8 +207,7 @@ def create_guess_scheme_t(args):def do_expected(self):url = guess_scheme(args[0])assert url.startswith(args[1]), \- 'Wrong scheme guessed: for `%s` got `%s`, expected `%s...`' % (- args[0], url, args[1])+ 'Wrong scheme guessed: for `%s` got `%s`, expected `%s...`' % (args[0], url, args[1])return do_expecteddiff --git a/tests/test_webclient.py b/tests/test_webclient.pyindex 188e54602..c1c5945c2 100644--- a/tests/test_webclient.py+++ b/tests/test_webclient.py@@ -356,9 +356,8 @@ class WebClientTestCase(unittest.TestCase):""" Test that non-standart body encoding matchesContent-Encoding header """body = b'\xd0\x81\xd1\x8e\xd0\xaf'- return getPage(- self.getURL('encoding'), body=body, response_transform=lambda r: r)\- .addCallback(self._check_Encoding, body)+ dfd = getPage(self.getURL('encoding'), body=body, response_transform=lambda r: r)+ return dfd.addCallback(self._check_Encoding, body)def _check_Encoding(self, response, original_body):content_encoding = to_unicode(response.headers[b'Content-Encoding'])