Skip to content

Commit acccdcc

Browse files
simonjayhawkinsWillAyd
authored andcommitted
TST/CLN: remove try block from test_indexing_over_size_cutoff_period_index (#27276)
1 parent 6bc1cf4 commit acccdcc

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

pandas/tests/series/indexing/test_datetime.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -604,28 +604,24 @@ def test_indexing_over_size_cutoff():
604604
_index._SIZE_CUTOFF = old_cutoff
605605

606606

607-
def test_indexing_over_size_cutoff_period_index():
607+
def test_indexing_over_size_cutoff_period_index(monkeypatch):
608608
# GH 27136
609609

610-
old_cutoff = _index._SIZE_CUTOFF
611-
try:
612-
_index._SIZE_CUTOFF = 1000
610+
monkeypatch.setattr(_index, "_SIZE_CUTOFF", 1000)
613611

614-
n = 1100
615-
idx = pd.period_range("1/1/2000", freq="T", periods=n)
616-
assert idx._engine.over_size_threshold
612+
n = 1100
613+
idx = pd.period_range("1/1/2000", freq="T", periods=n)
614+
assert idx._engine.over_size_threshold
617615

618-
s = pd.Series(np.random.randn(len(idx)), index=idx)
616+
s = pd.Series(np.random.randn(len(idx)), index=idx)
619617

620-
pos = n - 1
621-
timestamp = idx[pos]
622-
assert timestamp in s.index
618+
pos = n - 1
619+
timestamp = idx[pos]
620+
assert timestamp in s.index
623621

624-
# it works!
625-
s[timestamp]
626-
assert len(s.loc[[timestamp]]) > 0
627-
finally:
628-
_index._SIZE_CUTOFF = old_cutoff
622+
# it works!
623+
s[timestamp]
624+
assert len(s.loc[[timestamp]]) > 0
629625

630626

631627
def test_indexing_unordered():

0 commit comments

Comments
 (0)