Skip to content

Commit fc32405

Browse files
committed
ignore warnings on 3.12
1 parent 63d75c8 commit fc32405

File tree

4 files changed

+465
-369
lines changed

4 files changed

+465
-369
lines changed

tests/__init__.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,29 @@
77
)
88
import os
99
import platform
10+
import sys
1011
from typing import (
1112
TYPE_CHECKING,
1213
Final,
14+
TypeVar,
1315
)
1416

15-
import pandas as pd
16-
from pandas.util.version import Version
1717
import pytest
1818

19-
from pandas._typing import T
19+
if sys.version_info < (3, 12):
20+
import pandas as pd
21+
else:
22+
with pytest.warns(DeprecationWarning, match="datetime.datetime.utcfromtimestamp"):
23+
import pandas as pd
24+
from pandas.util.version import Version
2025

26+
_T = TypeVar("_T")
2127
TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING
2228
WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower()
2329
PD_LTE_21 = Version(pd.__version__) < Version("2.1.999")
2430

2531

26-
def check(actual: T, klass: type, dtype: type | None = None, attr: str = "left") -> T:
32+
def check(actual: _T, klass: type, dtype: type | None = None, attr: str = "left") -> _T:
2733
if not isinstance(actual, klass):
2834
raise RuntimeError(f"Expected type '{klass}' but got '{type(actual)}'")
2935
if dtype is None:

tests/test_frame.py

+25-18
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import io
1515
import itertools
1616
from pathlib import Path
17+
import platform
1718
import string
1819
from typing import (
1920
TYPE_CHECKING,
@@ -1821,24 +1822,30 @@ def test_frame_getitem_isin() -> None:
18211822
def test_to_excel() -> None:
18221823
df = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
18231824

1824-
with ensure_clean() as path:
1825-
df.to_excel(path, engine="openpyxl")
1826-
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1827-
with ensure_clean() as path:
1828-
df.to_excel(Path(path), engine="openpyxl")
1829-
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1830-
with ensure_clean() as path:
1831-
df.to_excel(path, engine="openpyxl", startrow=1, startcol=1, header=False)
1832-
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1833-
with ensure_clean() as path:
1834-
df.to_excel(path, engine="openpyxl", sheet_name="sheet", index=False)
1835-
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1836-
with ensure_clean() as path:
1837-
df.to_excel(path, engine="openpyxl", header=["x", "y"])
1838-
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1839-
with ensure_clean() as path:
1840-
df.to_excel(path, engine="openpyxl", columns=["col1"])
1841-
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1825+
with pytest_warns_bounded(
1826+
DeprecationWarning,
1827+
match="datetime.datetime.utcnow",
1828+
lower="3.11",
1829+
version_str=platform.python_version(),
1830+
):
1831+
with ensure_clean() as path:
1832+
df.to_excel(path, engine="openpyxl")
1833+
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1834+
with ensure_clean() as path:
1835+
df.to_excel(Path(path), engine="openpyxl")
1836+
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1837+
with ensure_clean() as path:
1838+
df.to_excel(path, engine="openpyxl", startrow=1, startcol=1, header=False)
1839+
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1840+
with ensure_clean() as path:
1841+
df.to_excel(path, engine="openpyxl", sheet_name="sheet", index=False)
1842+
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1843+
with ensure_clean() as path:
1844+
df.to_excel(path, engine="openpyxl", header=["x", "y"])
1845+
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1846+
with ensure_clean() as path:
1847+
df.to_excel(path, engine="openpyxl", columns=["col1"])
1848+
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
18421849

18431850

18441851
def test_join() -> None:

0 commit comments

Comments
 (0)