Skip to content

Commit 3c6a39a

Browse files
authored
Merge pull request #309 from Gallaecio/master
Prepare scrapy-splash 0.9.0
2 parents f5273b3 + cfb1ded commit 3c6a39a

File tree

10 files changed

+47
-56
lines changed

10 files changed

+47
-56
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,11 @@ jobs:
99
fail-fast: false
1010
matrix:
1111
include:
12-
- os: ubuntu-18.04
13-
python-version: 2.7
14-
env:
15-
TOXENV: py27
16-
- os: ubuntu-18.04
17-
python-version: 3.4
18-
env:
19-
TOXENV: py
20-
- os: ubuntu-18.04
21-
python-version: 3.5
22-
env:
23-
TOXENV: py35
24-
- python-version: 3.6
25-
env:
26-
TOXENV: py
27-
- python-version: 3.7
28-
env:
29-
TOXENV: py
30-
- python-version: 3.8
31-
env:
32-
TOXENV: py
12+
- python-version: '3.7'
13+
- python-version: '3.8'
14+
- python-version: '3.9'
15+
- python-version: '3.10'
16+
- python-version: '3.11'
3317

3418
steps:
3519
- uses: actions/checkout@v2
@@ -44,7 +28,8 @@ jobs:
4428
python-version: ${{ matrix.python-version }}
4529

4630
- name: Run tests
47-
env: ${{ matrix.env }}
31+
env:
32+
TOXENV: py
4833
run: |
4934
pip install -U tox
5035
SPLASH_URL=http://127.0.0.1:8050 tox

CHANGES.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
Changes
22
=======
33

4+
0.9.0 (to be released)
5+
----------------------
6+
7+
* Removed official support for Python 2.7, 3.4, 3.5 and 3.6, and added official
8+
support for Python 3.9, 3.10 and 3.11.
9+
10+
* Deprecated ``SplashJsonResponse.body_as_unicode()``, to be replaced by
11+
``SplashJsonResponse.text``.
12+
13+
* Removed calls to obsolete ``to_native_str``, removed in Scrapy 2.8.
14+
415
0.8.0 (2021-10-05)
516
------------------
617

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ Run a simple `Splash Lua Script`_::
460460

461461
# ...
462462
def parse_result(self, response):
463-
doc_title = response.body_as_unicode()
463+
doc_title = response.text
464464
# ...
465465

466466

scrapy_splash/request.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,11 @@ def _original_url(self):
9090
def _original_method(self):
9191
return self._splash_args.get('http_method', 'GET')
9292

93-
def __str__(self):
93+
def __repr__(self):
9494
if not self._processed:
95-
return super(SplashRequest, self).__str__()
95+
return super().__repr__()
9696
return "<%s %s via %s>" % (self._original_method, self._original_url, self.url)
9797

98-
__repr__ = __str__
99-
10098

10199
class SplashFormRequest(SplashRequest, FormRequest):
102100
"""

scrapy_splash/response.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import base64
66
import re
7+
from warnings import warn
78

89
from scrapy.http import Response, TextResponse
910
from scrapy import Selector
@@ -129,6 +130,14 @@ def text(self):
129130
return self._ubody
130131

131132
def body_as_unicode(self):
133+
warn(
134+
(
135+
"The body_as_unicode() method is deprecated, use the text "
136+
"property instead."
137+
),
138+
DeprecationWarning,
139+
stacklevel=2,
140+
)
132141
return self._ubody
133142

134143
@property

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name='scrapy-splash',
6-
version='0.7.2',
6+
version='0.8.0',
77
url='https://github.com/scrapy-plugins/scrapy-splash',
88
description='JavaScript support for Scrapy using Splash',
99
long_description=open('README.rst').read() + "\n\n" + open("CHANGES.rst").read(),

tests/test_fingerprints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66
import scrapy
7-
from scrapy.dupefilters import request_fingerprint
7+
from scrapy.utils.request import request_fingerprint
88

99
from scrapy_splash import SplashRequest
1010
from scrapy_splash.dupefilter import splash_request_fingerprint

tests/test_integration.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def test_access_http_auth(settings):
340340
items, url, crawler = yield crawl_items(LuaSpider, HelloWorldProtected,
341341
settings, kwargs)
342342
response = assert_single_response(items)
343-
assert 'hello' in response.body_as_unicode()
343+
assert 'hello' in response.text
344344
assert response.status == 200
345345
assert response.splash_response_status == 200
346346

@@ -351,8 +351,8 @@ def test_protected_splash_no_auth(settings_auth):
351351
items, url, crawler = yield crawl_items(LuaSpider, HelloWorld,
352352
settings_auth)
353353
response = assert_single_response(items)
354-
assert 'Unauthorized' in response.body_as_unicode()
355-
assert 'hello' not in response.body_as_unicode()
354+
assert 'Unauthorized' in response.text
355+
assert 'hello' not in response.text
356356
assert response.status == 401
357357
assert response.splash_response_status == 401
358358

@@ -367,15 +367,15 @@ def test_protected_splash_manual_headers_auth(settings_auth):
367367
items, url, crawler = yield crawl_items(LuaSpider, HelloWorld,
368368
settings_auth, kwargs)
369369
response = assert_single_response(items)
370-
assert 'hello' in response.body_as_unicode()
370+
assert 'hello' in response.text
371371
assert response.status == 200
372372
assert response.splash_response_status == 200
373373

374374
# but only for Splash, not for a remote website
375375
items, url, crawler = yield crawl_items(LuaSpider, HelloWorldProtected,
376376
settings_auth, kwargs)
377377
response = assert_single_response(items)
378-
assert 'hello' not in response.body_as_unicode()
378+
assert 'hello' not in response.text
379379
assert response.status == 401
380380
assert response.splash_response_status == 200
381381

@@ -390,8 +390,8 @@ def test_protected_splash_settings_auth(settings_auth):
390390
items, url, crawler = yield crawl_items(LuaSpider, HelloWorld,
391391
settings_auth)
392392
response = assert_single_response(items)
393-
assert 'Unauthorized' not in response.body_as_unicode()
394-
assert 'hello' in response.body_as_unicode()
393+
assert 'Unauthorized' not in response.text
394+
assert 'hello' in response.text
395395
assert response.status == 200
396396
assert response.splash_response_status == 200
397397

@@ -418,7 +418,7 @@ def test_protected_splash_settings_auth(settings_auth):
418418
response = assert_single_response(items)
419419
assert response.status == 200
420420
assert response.splash_response_status == 200
421-
assert 'hello' in response.body_as_unicode()
421+
assert 'hello' in response.text
422422

423423
# enable remote auth, but not splash auth - request should fail
424424
del settings_auth['SPLASH_USER']
@@ -439,8 +439,8 @@ def test_protected_splash_httpauth_middleware(settings_auth):
439439
items, url, crawler = yield crawl_items(ScrapyAuthSpider, HelloWorld,
440440
settings_auth)
441441
response = assert_single_response(items)
442-
assert 'Unauthorized' not in response.body_as_unicode()
443-
assert 'hello' in response.body_as_unicode()
442+
assert 'Unauthorized' not in response.text
443+
assert 'hello' in response.text
444444
assert response.status == 200
445445
assert response.splash_response_status == 200
446446

@@ -449,7 +449,7 @@ def test_protected_splash_httpauth_middleware(settings_auth):
449449
HelloWorldProtected,
450450
settings_auth)
451451
response = assert_single_response(items)
452-
assert 'hello' not in response.body_as_unicode()
452+
assert 'hello' not in response.text
453453
assert response.status == 401
454454
assert response.splash_response_status == 200
455455

@@ -458,7 +458,7 @@ def test_protected_splash_httpauth_middleware(settings_auth):
458458
HelloWorldDisallowAuth,
459459
settings_auth)
460460
response = assert_single_response(items)
461-
assert 'hello' in response.body_as_unicode()
461+
assert 'hello' in response.text
462462
assert response.status == 200
463463
assert response.splash_response_status == 200
464464

@@ -467,7 +467,7 @@ def test_protected_splash_httpauth_middleware(settings_auth):
467467
HelloWorldProtected,
468468
settings_auth)
469469
response = assert_single_response(items)
470-
assert 'hello' in response.body_as_unicode()
470+
assert 'hello' in response.text
471471
assert response.status == 200
472472
assert not hasattr(response, 'splash_response_status')
473473

tests/test_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def cb():
188188
assert response2.url == req.meta['splash']['args']['url']
189189
assert response2.data == res
190190
assert response2.body == res_body.encode('utf8')
191-
assert response2.text == response2.body_as_unicode() == res_body
191+
assert response2.text == response2.text == res_body
192192
assert response2.encoding == 'utf8'
193193
assert response2.headers == {b'Content-Type': [b'application/json']}
194194
assert response2.splash_response_headers == response2.headers

tox.ini

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = py27,py34,py35,py36,py37,py38
7+
envlist = py37,py38,py39,py310,py311
88

99
[common]
1010
deps =
@@ -24,15 +24,3 @@ deps =
2424
commands =
2525
pip install -e .
2626
py.test --doctest-modules --cov=scrapy_splash {posargs:scrapy_splash tests}
27-
28-
[testenv:py27]
29-
deps =
30-
{[common]deps}
31-
queuelib < 1.6.0
32-
scrapy < 2
33-
34-
[testenv:py35]
35-
deps =
36-
{[common]deps}
37-
# https://github.com/scrapy/scrapy/pull/4094#issuecomment-704092404
38-
scrapy < 2

0 commit comments

Comments
 (0)