diff -Nru python-cachecontrol-0.13.1/.bumpversion.cfg python-cachecontrol-0.14.0/.bumpversion.cfg --- python-cachecontrol-0.13.1/.bumpversion.cfg 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/.bumpversion.cfg 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -[bumpversion] -current_version = 0.13.0 -files = cachecontrol/__init__.py docs/conf.py -commit = True -tag = True diff -Nru python-cachecontrol-0.13.1/.github/workflows/release.yml python-cachecontrol-0.14.0/.github/workflows/release.yml --- python-cachecontrol-0.13.1/.github/workflows/release.yml 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/.github/workflows/release.yml 2024-02-02 02:50:04.000000000 +0000 @@ -19,11 +19,11 @@ contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: - python-version: ">= 3.6" + python-version: "3.x" - name: deps run: python -m pip install -U build @@ -35,7 +35,7 @@ uses: pypa/gh-action-pypi-publish@release/v1 - name: sign - uses: sigstore/gh-action-sigstore-python@v1.2.3 + uses: sigstore/gh-action-sigstore-python@v2.0.1 with: inputs: ./dist/*.tar.gz ./dist/*.whl release-signing-artifacts: true diff -Nru python-cachecontrol-0.13.1/.github/workflows/tests.yml python-cachecontrol-0.14.0/.github/workflows/tests.yml --- python-cachecontrol-0.13.1/.github/workflows/tests.yml 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/.github/workflows/tests.yml 2024-02-02 02:50:04.000000000 +0000 @@ -16,14 +16,15 @@ strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] os: ["macos-latest", "windows-latest", "ubuntu-latest"] steps: - - uses: "actions/checkout@v3" + - uses: "actions/checkout@v4" - uses: "actions/setup-python@v4" with: python-version: "${{ matrix.python-version }}" + allow-prereleases: true - name: "Install dependencies" run: | python -VV diff -Nru python-cachecontrol-0.13.1/Makefile python-cachecontrol-0.14.0/Makefile --- python-cachecontrol-0.13.1/Makefile 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/Makefile 2024-02-02 02:50:04.000000000 +0000 @@ -5,16 +5,12 @@ VENV=.venv VENV_CMD=python3 -m venv ACTIVATE = $(VENV)/bin/activate -CHEESE=https://pypi.python.org/pypi -BUMPTYPE=patch -BUMPPRE=0 - -$(VENV)/bin/pip3: +$(VENV)/bin/pip: $(VENV_CMD) $(VENV) -bootstrap: $(VENV)/bin/pip3 - $(VENV)/bin/pip3 install -e .[dev] +bootstrap: $(VENV)/bin/pip + $(VENV)/bin/pip install -e .[dev] format: $(VENV)/bin/black . diff -Nru python-cachecontrol-0.13.1/README.rst python-cachecontrol-0.14.0/README.rst --- python-cachecontrol-0.13.1/README.rst 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/README.rst 2024-02-02 02:50:04.000000000 +0000 @@ -35,7 +35,7 @@ sess = requests.session() cached_sess = CacheControl(sess) - response = cached_sess.get('http://google.com') + response = cached_sess.get('https://google.com') If the URL contains any caching based headers, it will cache the result in a simple dictionary. diff -Nru python-cachecontrol-0.13.1/cachecontrol/__init__.py python-cachecontrol-0.14.0/cachecontrol/__init__.py --- python-cachecontrol-0.13.1/cachecontrol/__init__.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/cachecontrol/__init__.py 2024-02-02 02:50:04.000000000 +0000 @@ -8,7 +8,7 @@ """ __author__ = "Eric Larson" __email__ = "eric@ionrock.org" -__version__ = "0.13.1" +__version__ = "0.14.0" from cachecontrol.adapter import CacheControlAdapter from cachecontrol.controller import CacheController diff -Nru python-cachecontrol-0.13.1/cachecontrol/adapter.py python-cachecontrol-0.14.0/cachecontrol/adapter.py --- python-cachecontrol-0.13.1/cachecontrol/adapter.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/cachecontrol/adapter.py 2024-02-02 02:50:04.000000000 +0000 @@ -125,21 +125,21 @@ else: # Wrap the response file with a wrapper that will cache the # response when the stream has been consumed. - response._fp = CallbackFileWrapper( # type: ignore[attr-defined] - response._fp, # type: ignore[attr-defined] + response._fp = CallbackFileWrapper( # type: ignore[assignment] + response._fp, # type: ignore[arg-type] functools.partial( self.controller.cache_response, request, response ), ) if response.chunked: - super_update_chunk_length = response._update_chunk_length # type: ignore[attr-defined] + super_update_chunk_length = response._update_chunk_length def _update_chunk_length(self: HTTPResponse) -> None: super_update_chunk_length() if self.chunk_left == 0: - self._fp._close() # type: ignore[attr-defined] + self._fp._close() # type: ignore[union-attr] - response._update_chunk_length = types.MethodType( # type: ignore[attr-defined] + response._update_chunk_length = types.MethodType( # type: ignore[method-assign] _update_chunk_length, response ) diff -Nru python-cachecontrol-0.13.1/cachecontrol/caches/file_cache.py python-cachecontrol-0.14.0/cachecontrol/caches/file_cache.py --- python-cachecontrol-0.13.1/cachecontrol/caches/file_cache.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/cachecontrol/caches/file_cache.py 2024-02-02 02:50:04.000000000 +0000 @@ -6,7 +6,8 @@ import hashlib import os from textwrap import dedent -from typing import IO, TYPE_CHECKING +from typing import IO, TYPE_CHECKING, Union +from pathlib import Path from cachecontrol.cache import BaseCache, SeparateBodyBaseCache from cachecontrol.controller import CacheController @@ -63,7 +64,7 @@ def __init__( self, - directory: str, + directory: str | Path, forever: bool = False, filemode: int = 0o0600, dirmode: int = 0o0700, @@ -79,7 +80,7 @@ """ NOTE: In order to use the FileCache you must have filelock installed. You can install it via pip: - pip install filelock + pip install cachecontrol[filecache] """ ) raise ImportError(notice) diff -Nru python-cachecontrol-0.13.1/cachecontrol/controller.py python-cachecontrol-0.14.0/cachecontrol/controller.py --- python-cachecontrol-0.13.1/cachecontrol/controller.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/cachecontrol/controller.py 2024-02-02 02:50:04.000000000 +0000 @@ -142,6 +142,11 @@ """ Load a cached response, or return None if it's not available. """ + # We do not support caching of partial content: so if the request contains a + # Range header then we don't want to load anything from the cache. + if "Range" in request.headers: + return None + cache_url = request.url assert cache_url is not None cache_data = self.cache.get(cache_url) @@ -480,7 +485,7 @@ cached_response.headers.update( { k: v - for k, v in response.headers.items() # type: ignore[no-untyped-call] + for k, v in response.headers.items() if k.lower() not in excluded_headers } ) diff -Nru python-cachecontrol-0.13.1/cachecontrol/heuristics.py python-cachecontrol-0.14.0/cachecontrol/heuristics.py --- python-cachecontrol-0.13.1/cachecontrol/heuristics.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/cachecontrol/heuristics.py 2024-02-02 02:50:04.000000000 +0000 @@ -68,7 +68,7 @@ if "expires" not in response.headers: date = parsedate(response.headers["date"]) - expires = expire_after(timedelta(days=1), date=datetime(*date[:6], tzinfo=timezone.utc)) # type: ignore[misc] + expires = expire_after(timedelta(days=1), date=datetime(*date[:6], tzinfo=timezone.utc)) # type: ignore[index,misc] headers["expires"] = datetime_to_header(expires) headers["cache-control"] = "public" return headers diff -Nru python-cachecontrol-0.13.1/cachecontrol/serialize.py python-cachecontrol-0.14.0/cachecontrol/serialize.py --- python-cachecontrol-0.13.1/cachecontrol/serialize.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/cachecontrol/serialize.py 2024-02-02 02:50:04.000000000 +0000 @@ -32,13 +32,13 @@ # also update the response with a new file handler to be # sure it acts as though it was never read. body = response.read(decode_content=False) - response._fp = io.BytesIO(body) # type: ignore[attr-defined] + response._fp = io.BytesIO(body) # type: ignore[assignment] response.length_remaining = len(body) data = { "response": { "body": body, # Empty bytestring if body is stored separately - "headers": {str(k): str(v) for k, v in response.headers.items()}, # type: ignore[no-untyped-call] + "headers": {str(k): str(v) for k, v in response.headers.items()}, "status": response.status, "version": response.version, "reason": str(response.reason), @@ -72,31 +72,14 @@ if not data: return None - # Determine what version of the serializer the data was serialized - # with - try: - ver, data = data.split(b",", 1) - except ValueError: - ver = b"cc=0" - - # Make sure that our "ver" is actually a version and isn't a false - # positive from a , being in the data stream. - if ver[:3] != b"cc=": - data = ver + data - ver = b"cc=0" - - # Get the version number out of the cc=N - verstr = ver.split(b"=", 1)[-1].decode("ascii") - - # Dispatch to the actual load method for the given version - try: - return getattr(self, f"_loads_v{verstr}")(request, data, body_file) # type: ignore[no-any-return] - - except AttributeError: - # This is a version we don't have a loads function for, so we'll - # just treat it as a miss and return None + # Previous versions of this library supported other serialization + # formats, but these have all been removed. + if not data.startswith(f"cc={self.serde_version},".encode()): return None + data = data[5:] + return self._loads_v4(request, data, body_file) + def prepare_response( self, request: PreparedRequest, @@ -149,49 +132,6 @@ return HTTPResponse(body=body, preload_content=False, **cached["response"]) - def _loads_v0( - self, - request: PreparedRequest, - data: bytes, - body_file: IO[bytes] | None = None, - ) -> None: - # The original legacy cache data. This doesn't contain enough - # information to construct everything we need, so we'll treat this as - # a miss. - return None - - def _loads_v1( - self, - request: PreparedRequest, - data: bytes, - body_file: IO[bytes] | None = None, - ) -> HTTPResponse | None: - # The "v1" pickled cache format. This is no longer supported - # for security reasons, so we treat it as a miss. - return None - - def _loads_v2( - self, - request: PreparedRequest, - data: bytes, - body_file: IO[bytes] | None = None, - ) -> HTTPResponse | None: - # The "v2" compressed base64 cache format. - # This has been removed due to age and poor size/performance - # characteristics, so we treat it as a miss. - return None - - def _loads_v3( - self, - request: PreparedRequest, - data: bytes, - body_file: IO[bytes] | None = None, - ) -> None: - # Due to Python 2 encoding issues, it's impossible to know for sure - # exactly how to load v3 entries, thus we'll treat these as a miss so - # that they get rewritten out as v4 entries. - return None - def _loads_v4( self, request: PreparedRequest, diff -Nru python-cachecontrol-0.13.1/debian/changelog python-cachecontrol-0.14.0/debian/changelog --- python-cachecontrol-0.13.1/debian/changelog 2023-06-10 21:32:24.000000000 +0000 +++ python-cachecontrol-0.14.0/debian/changelog 2024-02-07 20:11:27.000000000 +0000 @@ -1,3 +1,15 @@ +python-cachecontrol (0.14.0-1) unstable; urgency=medium + + [ Stefano Rivera ] + * New upstream release. + * Refresh patches. + * Bump copyright years. + + [ Alexandre Detiste ] + * Remove extraneous dependency on python3-mock. + + -- Stefano Rivera Wed, 07 Feb 2024 16:11:27 -0400 + python-cachecontrol (0.13.1-1) unstable; urgency=medium * New upstream release. (Closes: #1019705) diff -Nru python-cachecontrol-0.13.1/debian/control python-cachecontrol-0.14.0/debian/control --- python-cachecontrol-0.13.1/debian/control 2023-06-10 21:32:24.000000000 +0000 +++ python-cachecontrol-0.14.0/debian/control 2024-02-07 20:11:27.000000000 +0000 @@ -12,7 +12,6 @@ python3-all, python3-cherrypy3 , python3-filelock , - python3-mock , python3-msgpack , python3-pytest , python3-redis , diff -Nru python-cachecontrol-0.13.1/debian/copyright python-cachecontrol-0.14.0/debian/copyright --- python-cachecontrol-0.13.1/debian/copyright 2023-06-10 21:32:24.000000000 +0000 +++ python-cachecontrol-0.14.0/debian/copyright 2024-02-07 20:11:27.000000000 +0000 @@ -3,7 +3,7 @@ Source: https://github.com/ionrock/cachecontrol Files: * -Copyright: 2015-2022 Eric Larson +Copyright: 2015-2024 Eric Larson License: Apache-2.0 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ Files: debian/* Copyright: 2015 Barry Warsaw - 2021-2022 Stefano Rivera + 2021-2024 Stefano Rivera License: Expat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff -Nru python-cachecontrol-0.13.1/debian/patches/no-doesitcache-script.patch python-cachecontrol-0.14.0/debian/patches/no-doesitcache-script.patch --- python-cachecontrol-0.13.1/debian/patches/no-doesitcache-script.patch 2023-06-10 21:32:24.000000000 +0000 +++ python-cachecontrol-0.14.0/debian/patches/no-doesitcache-script.patch 2024-02-07 20:11:27.000000000 +0000 @@ -8,10 +8,10 @@ 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml -index ef55536..e44db2a 100644 +index b600b34..ad48a4e 100644 --- a/pyproject.toml +++ b/pyproject.toml -@@ -62,7 +62,7 @@ dev = [ +@@ -64,7 +64,7 @@ dev = [ ] [project.scripts] diff -Nru python-cachecontrol-0.13.1/debian/tests/control python-cachecontrol-0.14.0/debian/tests/control --- python-cachecontrol-0.13.1/debian/tests/control 2023-06-10 21:32:24.000000000 +0000 +++ python-cachecontrol-0.14.0/debian/tests/control 2024-02-07 20:11:27.000000000 +0000 @@ -4,7 +4,6 @@ python3-cachecontrol, python3-cherrypy3, python3-filelock, - python3-mock, python3-pytest, python3-redis Restrictions: allow-stderr diff -Nru python-cachecontrol-0.13.1/docs/conf.py python-cachecontrol-0.14.0/docs/conf.py --- python-cachecontrol-0.13.1/docs/conf.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/docs/conf.py 2024-02-02 02:50:04.000000000 +0000 @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # SPDX-FileCopyrightText: 2015 Eric Larson # # SPDX-License-Identifier: Apache-2.0 @@ -30,7 +28,12 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ["sphinx.ext.autodoc", "sphinx.ext.todo", "sphinx.ext.viewcode"] +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.todo", + "sphinx.ext.viewcode", + "sphinx_copybutton", +] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] @@ -86,7 +89,7 @@ # show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" +# pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] @@ -96,7 +99,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = "default" +html_theme = "furo" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff -Nru python-cachecontrol-0.13.1/docs/index.rst python-cachecontrol-0.14.0/docs/index.rst --- python-cachecontrol-0.13.1/docs/index.rst 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/docs/index.rst 2024-02-02 02:50:04.000000000 +0000 @@ -73,13 +73,13 @@ .. _httplib2: https://github.com/httplib2/httplib2 -.. _requests: http://docs.python-requests.org/ -.. _Editing the Web: http://www.w3.org/1999/04/Editing/ -.. _PyPI: https://pypi.python.org/pypi/CacheControl/ -.. _pip: http://www.pip-installer.org/ +.. _requests: https://requests.readthedocs.io/en/latest/ +.. _PyPI: https://pypi.org/project/CacheControl/ +.. _pip: https://pip.pypa.io/en/stable/ -Contents: +Contents +======== .. toctree:: :maxdepth: 2 @@ -89,8 +89,15 @@ etags custom_heuristics tips - release_notes +.. toctree:: + :hidden: + :caption: Development + :maxdepth: 2 + + release_notes + GitHub + PyPI Indices and tables diff -Nru python-cachecontrol-0.13.1/docs/release_notes.rst python-cachecontrol-0.14.0/docs/release_notes.rst --- python-cachecontrol-0.13.1/docs/release_notes.rst 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/docs/release_notes.rst 2024-02-02 02:50:04.000000000 +0000 @@ -7,6 +7,13 @@ Release Notes =============== +0.14.0 +====== + +* Explicitly allow ``pathlib.Path`` as a type for ``FileCache.directory``. +* Drop support for Python 3.7. Python 3.8 is now the minimum version. +* Don't use the cache to return a full response if a request has a Range header. + 0.13.1 ====== @@ -29,6 +36,18 @@ * Add type annotations. * Exclude the ``tests`` directory from the wheel. +0.12.14 +======= + +* Revert the change "switch lockfile to filelock" to fix the compatibility issue. + +0.12.13 +======= + +* Discard the ``strict`` attribute when serializing and deserializing responses. +* Fix the IncompleteRead error thrown by ``urllib3`` 2.0. +* Exclude the tests directory from the wheel. + 0.12.11 ======= diff -Nru python-cachecontrol-0.13.1/docs/requirements.txt python-cachecontrol-0.14.0/docs/requirements.txt --- python-cachecontrol-0.13.1/docs/requirements.txt 1970-01-01 00:00:00.000000000 +0000 +++ python-cachecontrol-0.14.0/docs/requirements.txt 2024-02-02 02:50:04.000000000 +0000 @@ -0,0 +1 @@ +.[dev] diff -Nru python-cachecontrol-0.13.1/docs/storage.rst python-cachecontrol-0.14.0/docs/storage.rst --- python-cachecontrol-0.13.1/docs/storage.rst 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/docs/storage.rst 2024-02-02 02:50:04.000000000 +0000 @@ -77,10 +77,10 @@ import requests from cachecontrol import CacheControl - from cachecontrol.caches SeparateBodyFileCache + from cachecontrol.caches import SeparateBodyFileCache sess = CacheControl(requests.Session(), - cache=SeparatedBodyFileCache('.web_cache')) + cache=SeparateBodyFileCache('.web_cache')) ``SeparateBodyFileCache`` supports the same options as ``FileCache``. diff -Nru python-cachecontrol-0.13.1/examples/benchmark.py python-cachecontrol-0.14.0/examples/benchmark.py --- python-cachecontrol-0.13.1/examples/benchmark.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/examples/benchmark.py 2024-02-02 02:50:04.000000000 +0000 @@ -13,16 +13,16 @@ HOST = "localhost" PORT = 8050 -URL = "http://{}:{}/".format(HOST, PORT) +URL = f"http://{HOST}:{PORT}/" -class Server(object): - +class Server: def __call__(self, env, sr): body = "Hello World!" status = "200 OK" headers = [ - ("Cache-Control", "max-age=%i" % (60 * 10)), ("Content-Type", "text/plain") + ("Cache-Control", "max-age=%i" % (60 * 10)), + ("Content-Type", "text/plain"), ] sr(status, headers) return body diff -Nru python-cachecontrol-0.13.1/pyproject.toml python-cachecontrol-0.14.0/pyproject.toml --- python-cachecontrol-0.13.1/pyproject.toml 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/pyproject.toml 2024-02-02 02:50:04.000000000 +0000 @@ -24,16 +24,16 @@ "Environment :: Web Environment", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", - "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", "Topic :: Internet :: WWW/HTTP", ] keywords = ["requests", "http", "caching", "web"] -dependencies = ["requests >= 2.16.0", "msgpack >= 0.5.2"] +dependencies = ["requests >= 2.16.0", "msgpack >= 0.5.2, < 2.0.0"] requires-python = ">=3.7" [project.urls] @@ -56,6 +56,8 @@ "pytest", "cherrypy", "sphinx", + "furo", + "sphinx-copybutton", "black", "types-redis", "types-requests", diff -Nru python-cachecontrol-0.13.1/tests/conftest.py python-cachecontrol-0.14.0/tests/conftest.py --- python-cachecontrol-0.13.1/tests/conftest.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/tests/conftest.py 2024-02-02 02:50:04.000000000 +0000 @@ -13,7 +13,6 @@ class SimpleApp: - def __init__(self): self.etag_count = 0 self.update_etag_string() @@ -109,7 +108,7 @@ headers = [ ("Content-Type", "text/plain"), ("Cache-Control", "max-age=5000"), - ("Content-Length", str(len(body))) + ("Content-Length", str(len(body))), ] start_response("200 OK", headers) return [body] diff -Nru python-cachecontrol-0.13.1/tests/test_adapter.py python-cachecontrol-0.14.0/tests/test_adapter.py --- python-cachecontrol-0.13.1/tests/test_adapter.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/tests/test_adapter.py 2024-02-02 02:50:04.000000000 +0000 @@ -35,7 +35,6 @@ class TestSessionActions: - def test_get_caches(self, url, sess): r2 = sess.get(url) assert r2.from_cache is True diff -Nru python-cachecontrol-0.13.1/tests/test_chunked_response.py python-cachecontrol-0.14.0/tests/test_chunked_response.py --- python-cachecontrol-0.13.1/tests/test_chunked_response.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/tests/test_chunked_response.py 2024-02-02 02:50:04.000000000 +0000 @@ -21,7 +21,6 @@ class TestChunkedResponses: - def test_cache_chunked_response(self, url, sess): """ Verify that an otherwise cacheable response is cached when the diff -Nru python-cachecontrol-0.13.1/tests/test_etag.py python-cachecontrol-0.14.0/tests/test_etag.py --- python-cachecontrol-0.13.1/tests/test_etag.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/tests/test_etag.py 2024-02-02 02:50:04.000000000 +0000 @@ -79,6 +79,31 @@ # Make sure we updated our cache with the new etag'd response. assert self.cache.get(self.etag_url) == resp.raw + def test_etags_get_no_cache(self, sess, server): + """A 'Cache-Control: no-cache' header stops us from using the cache directly, + but not from using the 'If-None-Match' header on the request.""" + # get our response + r = sess.get(self.etag_url) + assert "if-none-match" not in r.request.headers + + r = sess.get(self.etag_url, headers={"Cache-Control": "no-cache"}) + assert "if-none-match" in r.request.headers + assert r.status_code == 200 + + # This response does come from the cache, but only after the 304 response from + # the server told us that was fine. + assert r.from_cache + + def test_etags_get_with_range(self, sess, server): + """A 'Range' header stops us from using the cache altogether.""" + # get our response + r = sess.get(self.etag_url) + + r = sess.get(self.etag_url, headers={"Range": "0-10"}) + assert "if-none-match" not in r.request.headers + assert r.status_code == 200 + assert not r.from_cache + class TestDisabledETags: """Test our use of ETags when the response is stale and the diff -Nru python-cachecontrol-0.13.1/tests/test_max_age.py python-cachecontrol-0.14.0/tests/test_max_age.py --- python-cachecontrol-0.13.1/tests/test_max_age.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/tests/test_max_age.py 2024-02-02 02:50:04.000000000 +0000 @@ -11,7 +11,6 @@ class TestMaxAge: - @pytest.fixture() def sess(self, url): self.url = url diff -Nru python-cachecontrol-0.13.1/tests/test_regressions.py python-cachecontrol-0.14.0/tests/test_regressions.py --- python-cachecontrol-0.13.1/tests/test_regressions.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/tests/test_regressions.py 2024-02-02 02:50:04.000000000 +0000 @@ -2,7 +2,6 @@ # # SPDX-License-Identifier: Apache-2.0 -import sys import pytest @@ -13,10 +12,6 @@ class Test39: - - @pytest.mark.skipif( - sys.version.startswith("2"), reason="Only run this for python 3.x" - ) def test_file_cache_recognizes_consumed_file_handle(self, url): s = CacheControl(Session(), FileCache("web_cache")) the_url = url + "cache_60" diff -Nru python-cachecontrol-0.13.1/tests/test_storage_filecache.py python-cachecontrol-0.14.0/tests/test_storage_filecache.py --- python-cachecontrol-0.13.1/tests/test_storage_filecache.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/tests/test_storage_filecache.py 2024-02-02 02:50:04.000000000 +0000 @@ -25,7 +25,6 @@ class FileCacheTestsMixin: - FileCacheClass = None # Either FileCache or SeparateBodyFileCache @pytest.fixture() diff -Nru python-cachecontrol-0.13.1/tests/test_storage_redis.py python-cachecontrol-0.14.0/tests/test_storage_redis.py --- python-cachecontrol-0.13.1/tests/test_storage_redis.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/tests/test_storage_redis.py 2024-02-02 02:50:04.000000000 +0000 @@ -18,8 +18,7 @@ assert self.conn.setex.called def test_set_expiration_datetime_aware(self): - self.cache.set("foo", "bar", - expires=datetime(2014, 2, 2, tzinfo=timezone.utc)) + self.cache.set("foo", "bar", expires=datetime(2014, 2, 2, tzinfo=timezone.utc)) assert self.conn.setex.called def test_set_expiration_int(self): diff -Nru python-cachecontrol-0.13.1/tests/utils.py python-cachecontrol-0.14.0/tests/utils.py --- python-cachecontrol-0.13.1/tests/utils.py 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/tests/utils.py 2024-02-02 02:50:04.000000000 +0000 @@ -8,7 +8,6 @@ class NullSerializer(Serializer): - def dumps(self, request, response, body=None): return response @@ -20,6 +19,7 @@ class DummyResponse: """Match a ``urllib3.response.HTTPResponse``.""" + version = "1.1" reason = b"Because" strict = 0 diff -Nru python-cachecontrol-0.13.1/tox.ini python-cachecontrol-0.14.0/tox.ini --- python-cachecontrol-0.13.1/tox.ini 2023-06-08 05:26:31.000000000 +0000 +++ python-cachecontrol-0.14.0/tox.ini 2024-02-02 02:50:04.000000000 +0000 @@ -4,15 +4,16 @@ [tox] isolated_build = True -envlist = py{36,37,38,39,310,311}, mypy +envlist = py{37,38,39,310,311,312}, mypy [gh-actions] python = 3.7: py37 3.8: py38 3.9: py39 - 3.10: py310, mypy + 3.10: py310 3.11: py311 + 3.12: py312, mypy [testenv] deps = pytest