Skip to content

Commit e5e16fa

Browse files
committed
MAINT: avoid warnings from openpyxl on Python 3.12
1 parent 5a7af6d commit e5e16fa

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

larray/tests/test_checked_session.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import pytest
1+
import pickle
2+
import warnings
23

4+
import pytest
35
try:
46
import pydantic # noqa: F401
57
except ImportError:
68
pytest.skip("pydantic is required for testing Checked* classes", allow_module_level=True)
7-
8-
import pickle
99
import numpy as np
1010

1111
from larray import (CheckedSession, CheckedArray, Axis, AxisCollection, Group, Array,
@@ -398,7 +398,12 @@ def _test_io_cs(tmp_path, meta, engine, ext):
398398
cs = CheckedSessionExample()
399399

400400
with must_warn(UserWarning, match=r"'\w' is not declared in 'CheckedSessionExample'", num_expected=3):
401-
cs.load(fpath, engine=engine)
401+
with warnings.catch_warnings():
402+
warnings.filterwarnings("ignore",
403+
module='openpyxl',
404+
message=r"datetime.datetime.utcnow\(\) is deprecated.*")
405+
406+
cs.load(fpath, engine=engine)
402407

403408
# --- names ---
404409
# we do not use keys() since order of undeclared variables
@@ -418,7 +423,12 @@ def _test_io_cs(tmp_path, meta, engine, ext):
418423
e2 = ndtest((a4, 'b=b0..b2'))
419424
h2 = full_like(h, fill_value=10)
420425
with must_warn(UserWarning, match=r"No value passed for the declared variable '\w+'", num_expected=3):
421-
CheckedSessionExample(a=a4, a01=a4_01, e=e2, h=h2).save(fpath, overwrite=False, engine=engine)
426+
with warnings.catch_warnings():
427+
warnings.filterwarnings("ignore",
428+
module=r'openpyxl',
429+
message=r"datetime.datetime.utcnow\(\) is deprecated.*")
430+
431+
CheckedSessionExample(a=a4, a01=a4_01, e=e2, h=h2).save(fpath, overwrite=False, engine=engine)
422432
with must_warn(UserWarning, match=r"No value passed for the declared variable '\w+'", num_expected=7):
423433
cs = CheckedSessionExample()
424434

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ addopts = [
3838
filterwarnings = [
3939
# turn warnings into errors (unless they are explicitly handled in tests or ignored here)
4040
"error",
41+
# as of version 3.1.2, openpyxl uses datetime.datetime.utcnow() which is deprecated in Python 3.12
42+
"ignore::DeprecationWarning:openpyxl.*:",
4143
"ignore::DeprecationWarning:pyreadline.*:",
4244
"ignore::DeprecationWarning:pywintypes.*:",
4345
"ignore::DeprecationWarning:tables.*:",

0 commit comments

Comments
 (0)