Skip to content

Commit 1ec5859

Browse files
added fixture, updated test
1 parent 8884962 commit 1ec5859

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

pandas/conftest.py

+13
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,19 @@ def all_compare_operators(request):
218218
return request.param
219219

220220

221+
@pytest.fixture(params=['__le__', '__lt__', '__ge__', '__gt__'])
222+
def compare_operators_no_eq_ne(request):
223+
"""
224+
Fixture for dunder names for compare operations except == and !=
225+
226+
* >=
227+
* >
228+
* <
229+
* <=
230+
"""
231+
return request.param
232+
233+
221234
@pytest.fixture(params=[None, 'gzip', 'bz2', 'zip', 'xz'])
222235
def compression(request):
223236
"""

pandas/tests/scalar/test_nat.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from datetime import datetime, timedelta
2+
import operator
23

34
import numpy as np
45
import pytest
@@ -350,14 +351,12 @@ def test_to_numpy_alias():
350351
assert isna(expected) and isna(result)
351352

352353

353-
@pytest.mark.parametrize("op", [
354-
lambda a, b: a > b, lambda a, b: a >= b,
355-
lambda a, b: a < b, lambda a, b: a <= b
356-
])
357354
@pytest.mark.parametrize("other", [
358355
Timedelta(0), Timestamp(0)
359356
])
360-
def test_nat_comparisons(op, other):
357+
def test_nat_comparisons(compare_operators_no_eq_ne, other):
361358
# GH 26039
359+
short_opname = compare_operators_no_eq_ne.strip('_')
360+
op = getattr(operator, short_opname)
362361
assert op(NaT, other) is False
363362
assert op(other, NaT) is False

0 commit comments

Comments
 (0)