Repository: h2non/pook (language: python)

Issue:
Upgrade xmltodict 
The version of xmltodict conflicts with wechatpy, please upgrade it to 0.11.0


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
new file mode 100644
index 0000000..626ef12
--- /dev/null
+++ b/.github/workflows/ci_cd.yml
@@ -0,0 +1,79 @@
+name: "CI/CD"
+
+on:
+  pull_request:
+  push:
+    branches:
+      - main
+
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  # Don't continue building images for a PR if the PR is updated quickly
+  # For other workflows, allow them to complete and just block on them. This
+  # ensures deployments in particular to happen in series rather than parallel.
+  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+jobs:
+  flake8:
+    name: flake8
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+
+      - name: Setup Python
+        uses: actions/setup-python@v4
+        with:
+          python-version: '3.11'
+          cache: 'pip'
+
+      - name: Install dependencies
+        run: pip install -r requirements.txt -r requirements-dev.txt
+      
+      - name: Lint
+        run: flake8 pook tests
+
+  test:
+    name: test on ${{ matrix.config.py }}
+    runs-on: ${{ matrix.config.os }}
+    strategy:
+      fail-fast: false
+      matrix:
+        config:
+          - py: "3.11"
+            os: "ubuntu-22.04"
+          - py: "3.10"
+            os: "ubuntu-22.04"
+          - py: "3.9"
+            os: "ubuntu-22.04"
+          - py: "3.8"
+            os: "ubuntu-22.04"
+            # <3.8 are not available on ubuntu-latest (22.04)
+          - py: "3.7"
+            os: "ubuntu-20.04"
+          - py: "3.6"
+            os: "ubuntu-20.04"
+          - py: "pypy3.10"
+            os: "ubuntu-22.04"
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v3
+        with:
+          fetch-depth: 0
+
+      - name: Setup Python for test ${{ matrix.config.py }}
+        uses: actions/setup-python@v4
+        with:
+          python-version: ${{ matrix.config.py }}
+          cache: pip
+
+      - name: Install tox
+        run: python -m pip install tox
+
+      - name: Run test suite
+        run: tox run -e py
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 4f826ae..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-language: python
-
-python:
-  - 3.5
-  - 3.6
-  - 3.7
-  - 3.8
-  - 3.9
-  - 3.10
-  - pypy
-  - pypy3
-
-allow_failures:
-  - python: pypy
-
-install:
-  - pip install -r requirements.txt
-  - pip install -r requirements-dev.txt
-
-script:
-  - make test
-
-after_success:
-  coveralls
diff --git a/README.rst b/README.rst
index 572f109..ea733fa 100644
--- a/README.rst
+++ b/README.rst
@@ -31,8 +31,8 @@ Features
 -  Supports third-party mocking engines, such as `mocket`_.
 -  Fits good for painless test doubles.
 -  Does not support WebSocket traffic mocking.
--  Works with +3.5 (including PyPy).
--  Dependency-less: just 2 small dependencies for JSONSchema and XML tree comparison.
+-  Works with +3.6 (including PyPy).
+-  Dependency-less: just 3 small dependencies for JSONSchema, XML tree comparison, and URL parsing.
 
 
 Supported HTTP clients
diff --git a/pook/headers.py b/pook/headers.py
index 9119d77..26c9d38 100644
--- a/pook/headers.py
+++ b/pook/headers.py
@@ -3,8 +3,6 @@
 except ImportError:
     from collections import Mapping, MutableMapping
 
-from base64 import b64encode
-
 
 class HTTPHeaderDict(MutableMapping):
     """
diff --git a/pook/interceptors/urllib3.py b/pook/interceptors/urllib3.py
index 8565aa8..1380da8 100644
--- a/pook/interceptors/urllib3.py
+++ b/pook/interceptors/urllib3.py
@@ -12,7 +12,7 @@
 
 PATCHES = (
     'requests.packages.urllib3.connectionpool.HTTPConnectionPool.urlopen',
-    'urllib3.connectionpool.HTTPConnectionPool.urlopen'
+    'urllib3.connectionpool.HTTPConnectionPool.urlopen',
 )
 
 RESPONSE_CLASS = 'HTTPResponse'
diff --git a/requirements-dev.txt b/requirements-dev.txt
index d6cb5de..c09d25e 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,15 +1,14 @@
 flake8
 wheel>=0.29
 coveralls>=1.1
-pytest~=7.2.0
-pytest-cov~=4.0.0
-pytest-flakes~=1.0.1
+pytest~=7.0
+pytest-cov~=4.0.0; python_version == '3.11'
 nose~=1.3.7
 Sphinx~=1.4.8
 sphinx-rtd-theme~=0.1.9
 requests>=2.20.0
 urllib3>=1.24.2
 bumpversion~=0.5.3
-aiohttp~=3.8.3
+aiohttp~=3.8.3; python_version >= '3.7'
 mocket~=1.6.0
-pytest-asyncio~=0.20.3
+pytest-asyncio~=0.20.3; python_version >= '3.7'
diff --git a/requirements.txt b/requirements.txt
index 9485cf8..08f85d0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,3 @@
-jsonschema>=2.5.1
-xmltodict>=0.11.0
-furl>=0.5.6
+jsonschema~=4.0
+xmltodict>=0.13.0
+furl>=2.1.3
diff --git a/tox.ini b/tox.ini
index e29a86f..0ca9bd2 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = {py35,py36,py37,py38,py39,py310,py311,pypy}
+envlist = {py36,py37,py38,py39,py310,py311,pypy310}
 
 [testenv]
 setenv =
@@ -8,5 +8,9 @@ deps =
 	-r{toxinidir}/requirements.txt
 	-r{toxinidir}/requirements-dev.txt
 commands =
-	make lint
-	make test
+	pytest
+
+[testenv:py36]
+requires = virtualenv<20.22.0
+commands =
+    pytest -k 'not aiohttp'


Test patch:
diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py
new file mode 100644
index 0000000..4e9f988
--- /dev/null
+++ b/tests/unit/conftest.py
@@ -0,0 +1,16 @@
+import pytest
+
+import pook
+
+
+@pytest.fixture
+def pook_on():
+    """
+    Safely toggle pook on before a test, then off afterwards.
+
+    @pook.on does not mix with pytest marks. This works around
+    that limitation.
+    """
+    pook.on()
+    yield
+    pook.off()
diff --git a/tests/unit/interceptors/aiohttp_test.py b/tests/unit/interceptors/aiohttp_test.py
index 9bf0c7a..6a0fbb0 100644
--- a/tests/unit/interceptors/aiohttp_test.py
+++ b/tests/unit/interceptors/aiohttp_test.py
@@ -1,4 +1,8 @@
-import aiohttp
+import sys
+if sys.version_info >= (3, 7):
+    # Prevents import error when testing Python < 3.7
+    import aiohttp
+
 import pook
 import pytest
 
@@ -15,14 +19,6 @@
 ).read_bytes()
 
 
-@pytest.fixture
-def pook_on():
-    # Cannot use `@pook.on` with pytest marks
-    pook.on()
-    yield
-    pook.off()
-
-
 def _pook_url():
     return pook.head(URL).reply(200).mock
 
diff --git a/tests/unit/interceptors/urllib3_test.py b/tests/unit/interceptors/urllib3_test.py
index 0632240..6501126 100644
--- a/tests/unit/interceptors/urllib3_test.py
+++ b/tests/unit/interceptors/urllib3_test.py
@@ -2,6 +2,8 @@
 
 import urllib3
 import pook
+import pytest
+import sys
 
 from pathlib import Path
 
@@ -84,9 +86,16 @@ def test_binary_body_chunked():
     assert list(r.read_chunked()) == [binary_file]
 
 
-def test_post_with_headers():
-    # this test failed with urllib3 v2.0.3
-    pook.post('https://example.org').reply(200)
+@pytest.mark.xfail(
+    condition=sys.version_info < (3, 7),
+    reason=(
+        "urllib3 converts https to http with "
+        "port 443 and fails on header parsing"
+    )
+)
+def test_post_with_headers(pook_on):
+    mock = pook.post('https://example.com').header('k', 'v').reply(200).mock
     http = urllib3.PoolManager(headers={'k': 'v'})
-    resp = http.request('POST', 'https://example.org')
+    resp = http.request('POST', 'https://example.com', headers={'k': 'v'})
     assert resp.status == 200
+    assert len(mock.matches) == 1