Skip to content

Commit d479ce5

Browse files
authored
Add support for py3.11. Remove py27, py35, py36, py37 (#170)
1 parent 06fe95c commit d479ce5

File tree

5 files changed

+45
-36
lines changed

5 files changed

+45
-36
lines changed

.github/workflows/main.yml

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,60 +13,48 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
include:
16-
- python-version: "pypy3"
17-
env:
18-
TOXENV: "msgpack"
19-
- python-version: "pypy3"
20-
env:
21-
TOXENV: "json"
22-
23-
- python-version: "2.7"
24-
env:
25-
TOXENV: "msgpack"
26-
- python-version: "2.7"
27-
env:
28-
TOXENV: "json"
29-
- python-version: "3.5"
16+
- python-version: "3.8"
3017
env:
3118
TOXENV: "msgpack"
32-
- python-version: "3.5"
19+
- python-version: "3.8"
3320
env:
3421
TOXENV: "json"
35-
- python-version: "3.6"
22+
- python-version: "3.9"
3623
env:
3724
TOXENV: "msgpack"
38-
- python-version: "3.6"
25+
- python-version: "3.9"
3926
env:
4027
TOXENV: "json"
41-
- python-version: "3.7"
28+
- python-version: "3.10"
4229
env:
4330
TOXENV: "msgpack"
44-
- python-version: "3.7"
31+
- python-version: "3.10"
4532
env:
4633
TOXENV: "json"
47-
- python-version: "3.8"
34+
- python-version: "3.11"
4835
env:
4936
TOXENV: "msgpack"
50-
- python-version: "3.8"
37+
- python-version: "3.11"
5138
env:
5239
TOXENV: "json"
53-
- python-version: "3.9"
40+
- python-version: "3.12"
5441
env:
5542
TOXENV: "msgpack"
56-
- python-version: "3.9"
43+
- python-version: "3.12"
5744
env:
5845
TOXENV: "json"
59-
- python-version: "3.10"
46+
47+
- python-version: "pypy3.10-v7.3.13"
6048
env:
6149
TOXENV: "msgpack"
62-
- python-version: "3.10"
50+
- python-version: "pypy3.10-v7.3.13"
6351
env:
6452
TOXENV: "json"
6553

6654
steps:
6755
- uses: actions/checkout@v2
6856
- name: Set up Python ${{ matrix.python-version }}
69-
uses: actions/setup-python@v2
57+
uses: actions/setup-python@v5
7058
with:
7159
python-version: ${{ matrix.python-version }}
7260

setup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,17 @@
2828
package_data={'scrapinghub': ['VERSION']},
2929
install_requires=['requests>=1.0', 'retrying>=1.3.3', 'six>=1.10.0'],
3030
extras_require={'msgpack': mpack_required},
31-
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
31+
python_requires='>=3.8',
3232
classifiers=[
3333
'Development Status :: 5 - Production/Stable',
3434
'License :: OSI Approved :: BSD License',
3535
'Operating System :: OS Independent',
3636
'Programming Language :: Python',
37-
'Programming Language :: Python :: 2.7',
38-
'Programming Language :: Python :: 3.5',
39-
'Programming Language :: Python :: 3.6',
40-
'Programming Language :: Python :: 3.7',
4137
'Programming Language :: Python :: 3.8',
4238
'Programming Language :: Python :: 3.9',
4339
'Programming Language :: Python :: 3.10',
40+
'Programming Language :: Python :: 3.11',
41+
'Programming Language :: Python :: 3.12',
4442
'Programming Language :: Python :: Implementation :: CPython',
4543
'Programming Language :: Python :: Implementation :: PyPy',
4644
'Topic :: Internet :: WWW/HTTP',

tests/client/test_proxy.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,22 @@ def test_format_iter_filters():
4141

4242

4343
def test_item_resource_iter_no_params():
44-
items_proxy = _ItemsResourceProxy(mock.Mock, mock.Mock(), 'mocked_key')
44+
class MockClient:
45+
def __init__(self):
46+
self._hsclient = object()
47+
48+
items_proxy = _ItemsResourceProxy(mock.Mock, MockClient(), 'mocked_key')
4549
items_proxy._origin = mock.Mock()
4650
items_proxy.iter(count=123)
4751
assert items_proxy._origin.list.call_args == mock.call(None, count=123)
4852

4953

5054
def test_item_resource_iter_with_params():
51-
items_proxy = _ItemsResourceProxy(mock.Mock, mock.Mock(), 'mocked_key')
55+
class MockClient:
56+
def __init__(self):
57+
self._hsclient = object()
58+
59+
items_proxy = _ItemsResourceProxy(mock.Mock, MockClient(), 'mocked_key')
5260
items_proxy._origin = mock.Mock()
5361
items_proxy.iter(count=123, startts=12345)
5462
assert (items_proxy._origin.list.call_args ==

tests/conftest.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# -*- coding: utf-8 -*-
21
import base64
32
import os
43
import pickle
54
import pytest
65
import re
6+
import sys
77
import zlib
88

99
from scrapinghub.hubstorage.serialization import MSGPACK_AVAILABLE
@@ -31,6 +31,18 @@
3131
TEST_DASH_ENDPOINT = os.getenv('DASH_ENDPOINT', DEFAULT_DASH_ENDPOINT)
3232

3333

34+
# https://github.com/kevin1024/vcrpy/issues/719#issuecomment-1811544263
35+
def upgrade_cassette(cassette):
36+
for interaction in cassette['interactions']:
37+
response = interaction.get('response', {})
38+
headers = response.get('headers', {})
39+
contentType = headers.get('content-encoding') or headers.get('Content-Encoding')
40+
compressed_string = response['body']['string']
41+
if contentType and contentType[0] == 'gzip':
42+
response['body']['string'] = zlib.decompress(compressed_string, zlib.MAX_WBITS | 16)
43+
44+
45+
3446
class VCRGzipSerializer(object):
3547
"""Custom ZIP serializer for VCR.py."""
3648

@@ -45,7 +57,10 @@ def serialize(self, cassette_dict):
4557
def deserialize(self, cassette_string):
4658
# receives a string, must return a dict
4759
decoded = base64.b64decode(cassette_string.encode('utf8'))
48-
return pickle.loads(zlib.decompress(decoded))
60+
cassette = pickle.loads(zlib.decompress(decoded))
61+
if sys.version_info >= (3, 10):
62+
upgrade_cassette(cassette)
63+
return cassette
4964

5065

5166
def normalize_endpoint(uri, endpoint, default_endpoint):

tox.ini

Lines changed: 1 addition & 1 deletion
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 = py{27,35,36,py3,37,38,39}-{json,msgpack}
7+
envlist = py{py3,38,39,310,311,312}-{json,msgpack}
88

99
[testenv]
1010
deps =

0 commit comments

Comments
 (0)