Skip to content

Commit 9617471

Browse files
committed
py-requests-cache: update to 1.2.1, drop py38, add py314, run tests
1 parent 7ec6f4d commit 9617471

File tree

2 files changed

+73
-12
lines changed

2 files changed

+73
-12
lines changed

python/py-requests-cache/Portfile

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
22

33
PortSystem 1.0
4-
PortGroup github 1.0
54
PortGroup python 1.0
65

7-
github.setup requests-cache requests-cache 0.9.7 v
8-
# Change github.tarball_from to 'releases' or 'archive' next update
9-
github.tarball_from tarball
10-
revision 0
11-
checksums rmd160 906efa0234086b9041b5cfe5314d50ef75bbfa9f \
12-
sha256 b9237e58de2c75265892325e8b9876b17110137df8f7f6385b262c3384402faf \
13-
size 1543984
146
name py-requests-cache
7+
version 1.2.1
8+
revision 0
9+
checksums rmd160 f301018c1e3b03f0717f9328aab59f624576d94d \
10+
sha256 68abc986fdc5b8d0911318fbb5f7c80eebcd4d01bfacc6685ecf8876052511d1 \
11+
size 3018209
1512

1613
categories-append devel
1714
license BSD
@@ -23,18 +20,18 @@ description Transparent persistent cache for py-requests
2320
long_description {*}${description}
2421

2522
homepage https://requests-cache.readthedocs.io/en/stable/
23+
distname requests_cache-${version}
2624

27-
python.versions 38 310
25+
python.versions 310 311 312 313 314
2826
python.pep517_backend poetry
2927

3028
if {${name} ne ${subport}} {
31-
depends_build-append \
32-
port:py${python.version}-setuptools
29+
patchfiles patch-timemachine_tests.diff
3330

3431
depends_lib-append \
35-
port:py${python.version}-appdirs \
3632
port:py${python.version}-attrs \
3733
port:py${python.version}-cattrs \
34+
port:py${python.version}-platformdirs \
3835
port:py${python.version}-requests \
3936
port:py${python.version}-url-normalize \
4037
port:py${python.version}-urllib3
@@ -47,4 +44,17 @@ if {${name} ne ${subport}} {
4744
xinstall -m 0644 -W ${worksrcpath} README.md CONTRIBUTORS.md \
4845
LICENSE HISTORY.md ${destroot}${docdir}
4946
}
47+
48+
test.run yes
49+
test.target tests/unit \
50+
tests/compat \
51+
tests/integration/test_filesystem.py::TestFileDict \
52+
tests/integration/test_memory.py::TestMemoryDict \
53+
tests/integration/test_sqlite.py::TestSQLiteDict
54+
depends_test-append \
55+
port:py${python.version}-responses \
56+
port:py${python.version}-requests-mock \
57+
port:py${python.version}-rich \
58+
port:py${python.version}-time-machine \
59+
port:py${python.version}-timeout-decorator
5060
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
https://github.com/requests-cache/requests-cache/commit/94a98bda63dc8f7cb7e931063843cbd17c613905
2+
3+
From 9e6a50fc629cd1bd2c674911179f2e4f35b8f97e Mon Sep 17 00:00:00 2001
4+
From: Mark Mentovai <[email protected]>
5+
Date: Thu, 27 Nov 2025 00:31:18 -0500
6+
Subject: [PATCH] Fix 2 test_session time_travel tests
7+
MIME-Version: 1.0
8+
Content-Type: text/plain; charset=UTF-8
9+
Content-Transfer-Encoding: 8bit
10+
11+
The assertions on response.is_expired could fail, because
12+
CachedResponse.is_expired compares a resource’s expiration time to the
13+
current time, and this comparison was being done outside of the scope of
14+
the time-altering time_travel context manager.
15+
---
16+
tests/unit/test_session.py | 12 ++++++------
17+
1 file changed, 6 insertions(+), 6 deletions(-)
18+
19+
diff --git tests/unit/test_session.py tests/unit/test_session.py
20+
index 5e29881a30b5..b4de166c3e48 100644
21+
--- tests/unit/test_session.py
22+
+++ tests/unit/test_session.py
23+
@@ -475,9 +475,9 @@ def test_stale_if_error__error_code(url, mock_session):
24+
with time_travel(START_DT + timedelta(seconds=1.1)):
25+
response = mock_session.get(url)
26+
27+
- assert response.status_code == 200
28+
- assert response.from_cache is True
29+
- assert response.is_expired is True
30+
+ assert response.status_code == 200
31+
+ assert response.from_cache is True
32+
+ assert response.is_expired is True
33+
34+
35+
@skip_pypy
36+
@@ -496,9 +496,9 @@ def test_stale_if_error__error_code_in_allowable_codes(url, mock_session):
37+
with time_travel(START_DT + timedelta(seconds=1.1)):
38+
response = mock_session.get(url)
39+
40+
- assert response.status_code == 404
41+
- assert response.from_cache is False
42+
- assert response.is_expired is False
43+
+ assert response.status_code == 404
44+
+ assert response.from_cache is False
45+
+ assert response.is_expired is False
46+
47+
48+
@pytest.mark.parametrize('url', [MOCKED_URL_200_404, MOCKED_URL_ETAG_200_404])
49+
--
50+
2.52.0
51+

0 commit comments

Comments
 (0)