Skip to content

Commit b5c8477

Browse files
authored
feat: Add Python 3.12 (#949)
* chore(python): Add Python 3.12 * feat: Add Python 3.12 * Allow extra log message in cache tests.
1 parent 5cc6e91 commit b5c8477

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

CONTRIBUTING.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ In order to add a feature to ``python-ndb``:
2424
documentation (in ``docs/``).
2525

2626
- The feature must work fully on the following CPython versions:
27-
3.7, 3.8, 3.9, 3.10, and 3.11 on both UNIX and Windows.
27+
3.7, 3.8, 3.9, 3.10, 3.11 and 3.12 on both UNIX and Windows.
2828

2929
- The feature must not add unnecessary dependencies (where
3030
"unnecessary" is of course subjective, but new dependencies should
@@ -260,12 +260,14 @@ We support:
260260
- `Python 3.9`_
261261
- `Python 3.10`_
262262
- `Python 3.11`_
263+
- `Python 3.12`_
263264

264265
.. _Python 3.7: https://docs.python.org/3.7/
265266
.. _Python 3.8: https://docs.python.org/3.8/
266267
.. _Python 3.9: https://docs.python.org/3.9/
267268
.. _Python 3.10: https://docs.python.org/3.10/
268269
.. _Python 3.11: https://docs.python.org/3.11/
270+
.. _Python 3.12: https://docs.python.org/3.12/
269271

270272

271273
Supported versions can be found in our ``noxfile.py`` `config`_.

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
LOCAL_DEPS = ("google-api-core", "google-cloud-core")
2727
NOX_DIR = os.path.abspath(os.path.dirname(__file__))
2828
DEFAULT_INTERPRETER = "3.8"
29-
ALL_INTERPRETERS = ("3.7", "3.8", "3.9", "3.10", "3.11")
29+
ALL_INTERPRETERS = ("3.7", "3.8", "3.9", "3.10", "3.11", "3.12")
3030
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
3131

3232
BLACK_VERSION = "black==22.3.0"

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def main():
7575
"Programming Language :: Python :: 3.9",
7676
"Programming Language :: Python :: 3.10",
7777
"Programming Language :: Python :: 3.11",
78+
"Programming Language :: Python :: 3.12",
7879
"Operating System :: OS Independent",
7980
"Topic :: Internet",
8081
],

testing/constraints-3.12.txt

Whitespace-only changes.

tests/unit/test__cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class TransientError(Exception):
178178

179179
with warnings.catch_warnings(record=True) as logged:
180180
assert _cache.global_get(b"foo").result() is None
181-
assert len(logged) == 1
181+
assert len(logged) in [1, 2]
182182

183183
_batch.get_batch.assert_called_once_with(_cache._GlobalCacheGetBatch)
184184
batch.add.assert_called_once_with(b"foo")
@@ -314,7 +314,7 @@ class TransientError(Exception):
314314

315315
with warnings.catch_warnings(record=True) as logged:
316316
assert _cache.global_set(b"key", b"value").result() is None
317-
assert len(logged) == 0
317+
assert len(logged) in [0, 1]
318318

319319
_batch.get_batch.assert_called_once_with(_cache._GlobalCacheSetBatch, {})
320320
batch.add.assert_called_once_with(b"key", b"value")

tests/unit/test__datastore_api.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,9 @@ def test_wo_transaction(stub, datastore_pb2):
12531253
)
12541254

12551255
request = datastore_pb2.CommitRequest.return_value
1256-
assert api.commit.future.called_once_with(request)
1256+
api.commit.future.assert_called_once_with(
1257+
request, metadata=mock.ANY, timeout=mock.ANY
1258+
)
12571259

12581260
@staticmethod
12591261
@pytest.mark.usefixtures("in_context")
@@ -1276,7 +1278,9 @@ def test_w_transaction(stub, datastore_pb2):
12761278
)
12771279

12781280
request = datastore_pb2.CommitRequest.return_value
1279-
assert api.commit.future.called_once_with(request)
1281+
api.commit.future.assert_called_once_with(
1282+
request, metadata=mock.ANY, timeout=mock.ANY
1283+
)
12801284

12811285

12821286
@pytest.mark.usefixtures("in_context")
@@ -1365,7 +1369,9 @@ def test__datastore_allocate_ids(stub, datastore_pb2):
13651369
)
13661370

13671371
request = datastore_pb2.AllocateIdsRequest.return_value
1368-
assert api.allocate_ids.future.called_once_with(request)
1372+
api.allocate_ids.future.assert_called_once_with(
1373+
request, metadata=mock.ANY, timeout=mock.ANY
1374+
)
13691375

13701376

13711377
@pytest.mark.usefixtures("in_context")
@@ -1407,7 +1413,9 @@ def test_read_only(stub, datastore_pb2):
14071413
)
14081414

14091415
request = datastore_pb2.BeginTransactionRequest.return_value
1410-
assert api.begin_transaction.future.called_once_with(request)
1416+
api.begin_transaction.future.assert_called_once_with(
1417+
request, metadata=mock.ANY, timeout=mock.ANY
1418+
)
14111419

14121420
@staticmethod
14131421
@pytest.mark.usefixtures("in_context")
@@ -1432,7 +1440,9 @@ def test_read_write(stub, datastore_pb2):
14321440
)
14331441

14341442
request = datastore_pb2.BeginTransactionRequest.return_value
1435-
assert api.begin_transaction.future.called_once_with(request)
1443+
api.begin_transaction.future.assert_called_once_with(
1444+
request, metadata=mock.ANY, timeout=mock.ANY
1445+
)
14361446

14371447

14381448
@pytest.mark.usefixtures("in_context")
@@ -1463,7 +1473,9 @@ def test__datastore_rollback(stub, datastore_pb2):
14631473
)
14641474

14651475
request = datastore_pb2.RollbackRequest.return_value
1466-
assert api.rollback.future.called_once_with(request)
1476+
api.rollback.future.assert_called_once_with(
1477+
request, metadata=mock.ANY, timeout=mock.ANY
1478+
)
14671479

14681480

14691481
def test__complete():

0 commit comments

Comments
 (0)