Skip to content

Commit ec42541

Browse files
committed
OPT: add Python 3.13
1 parent e51cf94 commit ec42541

File tree

8 files changed

+848
-775
lines changed

8 files changed

+848
-775
lines changed

.github/workflows/check.yml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- '3.10'
2727
- '3.11'
2828
- '3.12'
29+
- '3.13'
2930

3031
services:
3132
redis:

Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
SRC := cachetory tests
2-
DJANGO_SETTINGS_MODULE := tests.backends.django.settings
1+
SRC = cachetory tests
32

43
.PHONY: all
54
all: install lint test build docs
@@ -37,7 +36,7 @@ format/ruff:
3736

3837
.PHONY: test
3938
test:
40-
poetry run pytest tests
39+
DJANGO_SETTINGS_MODULE=tests.backends.django.settings poetry run pytest tests
4140

4241
.PHONY: build
4342
build:

poetry.lock

+832-761
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ classifiers = [
2424
"Programming Language :: Python :: 3.10",
2525
"Programming Language :: Python :: 3.11",
2626
"Programming Language :: Python :: 3.12",
27+
"Programming Language :: Python :: 3.13",
2728
"Topic :: Internet :: WWW/HTTP",
2829
"Typing :: Typed",
2930
]
@@ -35,7 +36,7 @@ build-backend = "poetry_dynamic_versioning.backend"
3536
[tool.poetry.dependencies]
3637
django = {version = "^4.0.0 || ^5.0.0", optional = true}
3738
ormsgpack = {version = "^1.4.0", optional = true, markers = "platform_python_implementation == 'CPython'"}
38-
pydantic = ">2.0.0.0, <3.0.0.0"
39+
pydantic = "^2.0.0"
3940
python = "^3.9.0"
4041
redis = {version = "^4.4.2 || ^5.0.0", optional = true}
4142
typing-extensions = "^4.4.0"
@@ -144,6 +145,7 @@ strict = true
144145
[tool.pytest.ini_options]
145146
addopts = "--cov=./ --cov-report=xml"
146147
asyncio_mode = "auto"
148+
asyncio_default_fixture_loop_scope = "function"
147149

148150
[tool.coverage.run]
149151
source = ["cachetory"]

tests/backends/async_/test_django.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@pytest.fixture
99
async def backend() -> AsyncIterable[DjangoBackend[int]]:
1010
async with DjangoBackend[int].from_url("django://default") as backend:
11-
backend.clear()
11+
await backend.clear()
1212
try:
1313
yield backend
1414
finally:

tests/backends/django/settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
"LOCATION": "unique-snowflake",
55
},
66
}
7+
USE_TZ = True

tests/decorators/test_async.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ async def ttl(key: str) -> timedelta:
4646
async def expensive_function(**kwargs: Any) -> int:
4747
return 1
4848

49-
with mock.patch.object(cache, "set", wraps=cache.set) as m_set:
49+
with mock.patch.object(Cache, "set", wraps=cache.set) as set_mock:
5050
assert await expensive_function(a="a") == 1
5151

52-
m_set.assert_called_with(mock.ANY, mock.ANY, time_to_live=timedelta(seconds=42), if_not_exists=mock.ANY)
52+
set_mock.assert_called_with(mock.ANY, mock.ANY, time_to_live=timedelta(seconds=42), if_not_exists=mock.ANY)
5353

5454

5555
async def test_exclude(cache: Cache[int, int]) -> None:
5656
@cached(
5757
cache,
5858
make_key=lambda _, arg: str(arg),
59-
exclude=lambda key_, value_: int(key_) + value_ < 40,
59+
exclude=lambda key, _: key == "5",
6060
)
6161
async def power_function(arg: int) -> int:
6262
return arg**2

tests/decorators/test_sync.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,23 @@ def ttl(key: str) -> timedelta:
4646
def expensive_function(**kwargs: Any) -> int:
4747
return 1
4848

49-
with mock.patch.object(cache, "set", wraps=cache.set) as m_set:
49+
with mock.patch.object(Cache, "set", wraps=cache.set) as set_mock:
5050
assert expensive_function(a="a") == 1
5151

52-
m_set.assert_called_with(mock.ANY, mock.ANY, time_to_live=timedelta(seconds=42), if_not_exists=mock.ANY)
52+
set_mock.assert_called_with(mock.ANY, mock.ANY, time_to_live=timedelta(seconds=42), if_not_exists=mock.ANY)
5353

5454

5555
def test_exclude(cache: Cache[int, int]) -> None:
5656
@cached(
5757
cache,
5858
make_key=lambda _, arg: str(arg),
59-
exclude=lambda key_, value_: int(key_) + value_ < 40,
59+
exclude=lambda key, _: key == "5",
6060
)
6161
def power_function(arg: int) -> int:
6262
return arg**2
6363

64-
with mock.patch.object(cache, "set", wraps=cache.set):
65-
assert power_function(5) == 25
66-
assert power_function(6) == 36
64+
assert power_function(5) == 25
65+
assert power_function(6) == 36
6766

6867
assert cache.get("5") is None
6968
assert cache.get("6") == 36

0 commit comments

Comments
 (0)