Skip to content

Commit

Permalink
Drop support for Python 3.8 (#141)
Browse files Browse the repository at this point in the history
* Drop support for Python 3.8

* Update GitHub Action versions

* Update and run pre-commit and hooks

* Do not use No Content status code when testing responses with bodies

* Remove redundant function

This kind of string/bytes handling is no longer necessary since pook
v2.0.0 where all bodies are handled as bytes, and converted at the
edges. Internal library functions do not need to handle non-string
bodies.

* Update versions of libraries used for testing

* Update History.rst
  • Loading branch information
sarayourfriend authored Oct 8, 2024
1 parent 3e3a93d commit 15829a2
Show file tree
Hide file tree
Showing 71 changed files with 212 additions and 202 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:

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:
Expand All @@ -26,7 +23,7 @@ jobs:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
Expand All @@ -48,7 +45,7 @@ jobs:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
Expand All @@ -67,7 +64,7 @@ jobs:

test:
name: test on ${{ matrix.py }}
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand All @@ -77,16 +74,15 @@ jobs:
- '3.11'
- '3.10'
- '3.9'
- '3.8'

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Python for test ${{ matrix.py }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
cache: pip
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
Expand All @@ -21,7 +21,7 @@ repos:
- id: requirements-txt-fixer

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.6.9
hooks:
- id: ruff
args: [--fix]
Expand Down
5 changes: 5 additions & 0 deletions History.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
History
=======

v2.1.0 / 2024-10-08
-------------------------

* Drop support for Python 3.8 (it is EOL 2024-10-07)

v2.0.1 / 2024-10-08
-------------------------

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Features
- Supports third-party mocking engines, such as `mocket`_.
- Fits good for painless test doubles.
- Does not support WebSocket traffic mocking.
- Works with +3.8 (including PyPy).
- Works with +3.9 (including PyPy).
- Dependency-less: just 3 small dependencies for JSONSchema, XML tree comparison, and URL parsing.


Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
sys.path.insert(0, os.path.abspath(".."))

import pook # noqa
import sphinx_rtd_theme # noqa
import sphinx_rtd_theme

# -- General configuration ------------------------------------------------

Expand Down
5 changes: 3 additions & 2 deletions examples/chainable_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json
import pook

import requests

import pook

# Enable mock engine
pook.on()
Expand All @@ -11,7 +12,7 @@
.json({"foo": "bar"})
.type("json")
.header("Client", "requests")
.reply(204)
.reply(201)
.headers({"server": "pook"})
.json({"error": "simulated"})
)
Expand Down
2 changes: 1 addition & 1 deletion examples/context_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pook
import requests

import pook

with pook.api.context():
pook.get(
Expand Down
3 changes: 2 additions & 1 deletion examples/decorator_activate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pook
import requests

import pook


@pook.on
def run():
Expand Down
3 changes: 2 additions & 1 deletion examples/decorators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pook
import requests

import pook


@pook.get("http://httpbin.org/status/500", reply=204)
@pook.get("http://httpbin.org/status/400", reply=200, persist=True)
Expand Down
2 changes: 1 addition & 1 deletion examples/http_client_native.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import http.client
import pook

import pook

# Enable mock engine
pook.on()
Expand Down
6 changes: 4 additions & 2 deletions examples/json_matching.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import json
import pook

import requests

import pook

# Enable mock engine
pook.on()

(
pook.post("httpbin.org/post")
.json({"foo": "bar"})
.reply(204)
.reply(201)
.json({"error": "simulated"})
)

Expand Down
5 changes: 3 additions & 2 deletions examples/json_schema.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json
import pook

import requests

import pook

schema = {
"type": "object",
Expand All @@ -16,7 +17,7 @@
(
pook.post("httpbin.org/post")
.jsonschema(schema)
.reply(204)
.reply(201)
.json({"error": "simulated"})
)

Expand Down
3 changes: 2 additions & 1 deletion examples/match_callback.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pook
import requests

import pook


def on_match(request, mock):
print("On match:", request, mock)
Expand Down
2 changes: 1 addition & 1 deletion examples/mock_context_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pook
import requests

import pook

# Define a new mock that will be only active within the context manager
with pook.get(
Expand Down
3 changes: 2 additions & 1 deletion examples/mocket_example.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Be sure you have `mocket` installed:
# $ pip install mocket

import pook
import requests
from mocket.plugins.pook_mock_engine import MocketEngine

import pook

# Use mocket library as underlying mock engine
pook.set_mock_engine(MocketEngine)

Expand Down
4 changes: 2 additions & 2 deletions examples/network_mode.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pook
import requests

import pook

# Enable mock engine
pook.on()
Expand All @@ -10,7 +10,7 @@

(
pook.get("httpbin.org/headers")
.reply(204)
.reply(201)
.headers({"server": "pook"})
.json({"error": "simulated"})
)
Expand Down
4 changes: 2 additions & 2 deletions examples/network_mode_httpx.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pook
import httpx

import pook

# Enable mock engine
pook.on()
Expand All @@ -10,7 +10,7 @@

(
pook.get("httpbin.org/headers")
.reply(204)
.reply(201)
.headers({"server": "pook"})
.json({"error": "simulated"})
)
Expand Down
2 changes: 1 addition & 1 deletion examples/persistent_mock.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pook
import requests

import pook

# Enable mock engine
pook.on()
Expand Down
3 changes: 2 additions & 1 deletion examples/pytest_example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import pook
import pytest
import requests

import pook


@pook.activate
def test_simple_pook_request():
Expand Down
7 changes: 4 additions & 3 deletions examples/query_params_matching.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import pook
import requests

import pook

# Enable mock engine
pook.on()

(
pook.get("httpbin.org/get")
.params({"foo": "bar"})
.reply(204)
.reply(201)
.json({"error": "simulated"})
)

res = requests.get("http://httpbin.org/get", params={"foo": "bar"})

assert res.status_code == 204
assert res.status_code == 201
assert res.json() == {"error": "simulated"}
assert pook.isdone()
assert pook.pending_mocks() == []
2 changes: 1 addition & 1 deletion examples/regex.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pook
import requests

import pook

# Enable mock engine
pook.on()
Expand Down
2 changes: 1 addition & 1 deletion examples/requests_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pook
import requests

import pook

# Enable mock engine
pook.on()
Expand Down
2 changes: 1 addition & 1 deletion examples/simulated_error.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pook
import requests

import pook

# Enable mock engine
pook.on()
Expand Down
2 changes: 1 addition & 1 deletion examples/time_ttl_mock.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pook
import requests

import pook

# Enable mock engine
pook.on()
Expand Down
4 changes: 3 additions & 1 deletion examples/unittest_example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pook
import unittest

import requests

import pook


class TestUnitTestEngine(unittest.TestCase):
@pook.on
Expand Down
2 changes: 1 addition & 1 deletion examples/urllib3_chunked_response.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pook
import urllib3

import pook

# Mock HTTP traffic only in the given context
with pook.use():
Expand Down
2 changes: 1 addition & 1 deletion examples/urllib3_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pook
import urllib3

import pook

# Mock HTTP traffic only in the given context
with pook.use():
Expand Down
Loading

0 comments on commit 15829a2

Please sign in to comment.