Skip to content

Commit

Permalink
Add support for py3.11. Remove py27, py35, py36, py37 (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
elacuesta committed Jan 18, 2024
1 parent 06fe95c commit d479ce5
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 36 deletions.
40 changes: 14 additions & 26 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,48 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: "pypy3"
env:
TOXENV: "msgpack"
- python-version: "pypy3"
env:
TOXENV: "json"

- python-version: "2.7"
env:
TOXENV: "msgpack"
- python-version: "2.7"
env:
TOXENV: "json"
- python-version: "3.5"
- python-version: "3.8"
env:
TOXENV: "msgpack"
- python-version: "3.5"
- python-version: "3.8"
env:
TOXENV: "json"
- python-version: "3.6"
- python-version: "3.9"
env:
TOXENV: "msgpack"
- python-version: "3.6"
- python-version: "3.9"
env:
TOXENV: "json"
- python-version: "3.7"
- python-version: "3.10"
env:
TOXENV: "msgpack"
- python-version: "3.7"
- python-version: "3.10"
env:
TOXENV: "json"
- python-version: "3.8"
- python-version: "3.11"
env:
TOXENV: "msgpack"
- python-version: "3.8"
- python-version: "3.11"
env:
TOXENV: "json"
- python-version: "3.9"
- python-version: "3.12"
env:
TOXENV: "msgpack"
- python-version: "3.9"
- python-version: "3.12"
env:
TOXENV: "json"
- python-version: "3.10"

- python-version: "pypy3.10-v7.3.13"
env:
TOXENV: "msgpack"
- python-version: "3.10"
- python-version: "pypy3.10-v7.3.13"
env:
TOXENV: "json"

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@
package_data={'scrapinghub': ['VERSION']},
install_requires=['requests>=1.0', 'retrying>=1.3.3', 'six>=1.10.0'],
extras_require={'msgpack': mpack_required},
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
python_requires='>=3.8',
classifiers=[
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Internet :: WWW/HTTP',
Expand Down
12 changes: 10 additions & 2 deletions tests/client/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,22 @@ def test_format_iter_filters():


def test_item_resource_iter_no_params():
items_proxy = _ItemsResourceProxy(mock.Mock, mock.Mock(), 'mocked_key')
class MockClient:
def __init__(self):
self._hsclient = object()

items_proxy = _ItemsResourceProxy(mock.Mock, MockClient(), 'mocked_key')
items_proxy._origin = mock.Mock()
items_proxy.iter(count=123)
assert items_proxy._origin.list.call_args == mock.call(None, count=123)


def test_item_resource_iter_with_params():
items_proxy = _ItemsResourceProxy(mock.Mock, mock.Mock(), 'mocked_key')
class MockClient:
def __init__(self):
self._hsclient = object()

items_proxy = _ItemsResourceProxy(mock.Mock, MockClient(), 'mocked_key')
items_proxy._origin = mock.Mock()
items_proxy.iter(count=123, startts=12345)
assert (items_proxy._origin.list.call_args ==
Expand Down
19 changes: 17 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
import base64
import os
import pickle
import pytest
import re
import sys
import zlib

from scrapinghub.hubstorage.serialization import MSGPACK_AVAILABLE
Expand Down Expand Up @@ -31,6 +31,18 @@
TEST_DASH_ENDPOINT = os.getenv('DASH_ENDPOINT', DEFAULT_DASH_ENDPOINT)


# https://github.com/kevin1024/vcrpy/issues/719#issuecomment-1811544263
def upgrade_cassette(cassette):
for interaction in cassette['interactions']:
response = interaction.get('response', {})
headers = response.get('headers', {})
contentType = headers.get('content-encoding') or headers.get('Content-Encoding')
compressed_string = response['body']['string']
if contentType and contentType[0] == 'gzip':
response['body']['string'] = zlib.decompress(compressed_string, zlib.MAX_WBITS | 16)



class VCRGzipSerializer(object):
"""Custom ZIP serializer for VCR.py."""

Expand All @@ -45,7 +57,10 @@ def serialize(self, cassette_dict):
def deserialize(self, cassette_string):
# receives a string, must return a dict
decoded = base64.b64decode(cassette_string.encode('utf8'))
return pickle.loads(zlib.decompress(decoded))
cassette = pickle.loads(zlib.decompress(decoded))
if sys.version_info >= (3, 10):
upgrade_cassette(cassette)
return cassette


def normalize_endpoint(uri, endpoint, default_endpoint):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py{27,35,36,py3,37,38,39}-{json,msgpack}
envlist = py{py3,38,39,310,311,312}-{json,msgpack}

[testenv]
deps =
Expand Down

0 comments on commit d479ce5

Please sign in to comment.