Skip to content

Commit 1421c5d

Browse files
committed
pre-commit passing
1 parent c01ecfd commit 1421c5d

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

pandas/tests/scalar/timedelta/test_arithmetic.py

+15-13
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
import sys
1010
from typing import Hashable
1111

12-
import numpy as np
13-
import pytest
1412
from hypothesis import given
1513
from hypothesis.strategies import integers
14+
import numpy as np
15+
import pytest
1616

1717
from pandas.errors import OutOfBoundsTimedelta
1818

@@ -1147,13 +1147,18 @@ def test_compare_unknown_type(self, val):
11471147
with pytest.raises(TypeError, match=msg):
11481148
t < val
11491149

1150+
@pytest.mark.xfail(
1151+
reason="pd.Timedelta violates hash invariant (GH#44504).",
1152+
raises=AssertionError,
1153+
strict=True,
1154+
)
11501155
@given(integers(min_value=-sys.maxsize - 1, max_value=sys.maxsize))
1151-
def test_hash_invariant(value: int) -> None:
1156+
def test_hash_invariant(self, value: int) -> None:
11521157
"""Reproducing GH#44504
1153-
1158+
11541159
See: https://github.com/pandas-dev/pandas/issues/44504
11551160
"""
1156-
1161+
11571162
# See: UnitChoices in pandas/_libs/tslibs/timedeltas.pyi
11581163
unit_choices = (
11591164
"W",
@@ -1195,23 +1200,20 @@ def test_hash_invariant(value: int) -> None:
11951200
"nanosecond",
11961201
"n",
11971202
)
1198-
1203+
11991204
def _hash_invariance_upheld(v1: Hashable, v2: Hashable) -> bool:
12001205
if v1 != v2:
12011206
return True
1202-
1207+
12031208
# See: https://docs.python.org/3/glossary.html#term-hashable
12041209
# Hashable objects which compare equal must have the same hash value.
12051210
return hash(v1) == hash(v2)
1206-
1211+
12071212
for unit in unit_choices:
12081213
pd_td = Timedelta(value, unit)
12091214
np_td = np.timedelta64(value)
1210-
1211-
try:
1212-
assert _hash_invariance_upheld(pd_td, np_td)
1213-
except AssertionError:
1214-
pytest.xfail("pd.Timedelta violates hash invariant (GH#44504).")
1215+
1216+
assert _hash_invariance_upheld(pd_td, np_td)
12151217

12161218

12171219
def test_ops_notimplemented():

0 commit comments

Comments
 (0)