From 4c76f8a000eeb021f1e1d6f32dd233a7e1da7d96 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 18 Feb 2025 19:00:13 +0200 Subject: [PATCH 1/2] Drop support for EOL Python 3.6 --- .github/workflows/tests.yml | 2 -- setup.py | 3 +-- tox.ini | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 209cf7d..fb6762d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,8 +21,6 @@ jobs: # The forced pytest versions correspond with the lower bounds in tox.ini pytest-version: ['', '--force-dep pytest==4.6', '--force-dep pytest==6.2.4'] include: - - os: 'ubuntu-20.04' - python-version: '3.6' - os: 'ubuntu-22.04' python-version: '3.7' - os: 'ubuntu-22.04' diff --git a/setup.py b/setup.py index f934cef..e8210b4 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ def run(self): long_description=read("README.rst"), url="https://github.com/pytest-dev/pytest-localserver", packages=["pytest_localserver"], - python_requires=">=3.6", + python_requires=">=3.7", install_requires=["werkzeug>=0.10"], extras_require={ "smtp": [ @@ -59,7 +59,6 @@ def run(self): "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", diff --git a/tox.ini b/tox.ini index 7b22335..e2ef4ac 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{36,37,38,39,310,311,312,313,py3}{,-smtp},lint +envlist = py{37,38,39,310,311,312,313,py3}{,-smtp},lint recreate = True isolated_build = True From 06495a1949b395edf59fe7d3d5df5edcce5e5d2f Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 18 Feb 2025 19:00:59 +0200 Subject: [PATCH 2/2] Upgrade Python syntax --- .pre-commit-config.yaml | 2 +- pytest_localserver/http.py | 2 +- tests/test_http.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4df19b1..f932f4a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: rev: v3.19.1 hooks: - id: pyupgrade - args: [--py3-plus] + args: [--py37-plus] - repo: https://github.com/rhysd/actionlint rev: v1.7.7 diff --git a/pytest_localserver/http.py b/pytest_localserver/http.py index a4c3bef..3998ba2 100644 --- a/pytest_localserver/http.py +++ b/pytest_localserver/http.py @@ -56,7 +56,7 @@ def __bool__(self): def _encode_chunk(chunk, charset): if isinstance(chunk, str): chunk = chunk.encode(charset) - return "{:x}".format(len(chunk)).encode(charset) + b"\r\n" + chunk + b"\r\n" + return f"{len(chunk):x}".encode(charset) + b"\r\n" + chunk + b"\r\n" class ContentServer(WSGIServer): diff --git a/tests/test_http.py b/tests/test_http.py index 904e6ae..11902fd 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -241,7 +241,7 @@ def _format_chunk(chunk): if len(r) <= 40: return r else: - return r[:13] + "..." + r[-14:] + " (length {})".format(len(chunk)) + return r[:13] + "..." + r[-14:] + f" (length {len(chunk)})" def _compare_chunks(expected, actual): @@ -252,7 +252,7 @@ def _compare_chunks(expected, actual): for i, (e, a) in enumerate(itertools.zip_longest(expected, actual, fillvalue="")): if e != a: message += [ - " Chunks differ at index {}:".format(i), + f" Chunks differ at index {i}:", " Expected: " + (repr(expected[i : i + 5]) + "..." if e != "" else ""), " Found: " + (repr(actual[i : i + 5]) + "..." if a != "" else ""), ]