Skip to content

Commit ca8f96b

Browse files
committed
TST: tests for maybe_promote (precursor to #23982)
1 parent df771cc commit ca8f96b

File tree

2 files changed

+682
-7
lines changed

2 files changed

+682
-7
lines changed

pandas/conftest.py

+58-7
Original file line numberDiff line numberDiff line change
@@ -367,28 +367,39 @@ def unique_nulls_fixture(request):
367367
TIMEZONES = [None, 'UTC', 'US/Eastern', 'Asia/Tokyo', 'dateutil/US/Pacific',
368368
'dateutil/Asia/Singapore', tzutc(), tzlocal(), FixedOffset(300),
369369
FixedOffset(0), FixedOffset(-300)]
370+
TIMEZONE_IDS = ['None', 'UTC', 'US/Eastern', 'Asia/Tokyp',
371+
'dateutil/US/Pacific', 'dateutil/Asia/Singapore',
372+
'dateutil.tz.tzutz()', 'dateutil.tz.tzlocal()',
373+
'pytz.FixedOffset(300)', 'pytz.FixedOffset(0)',
374+
'pytz.FixedOffset(-300)']
370375

371376

372-
@td.parametrize_fixture_doc(str(TIMEZONES))
373-
@pytest.fixture(params=TIMEZONES)
377+
@td.parametrize_fixture_doc(str(TIMEZONE_IDS))
378+
@pytest.fixture(params=TIMEZONES, ids=TIMEZONE_IDS)
374379
def tz_naive_fixture(request):
375380
"""
376381
Fixture for trying timezones including default (None): {0}
377382
"""
378383
return request.param
379384

380385

381-
@td.parametrize_fixture_doc(str(TIMEZONES[1:]))
382-
@pytest.fixture(params=TIMEZONES[1:])
386+
@td.parametrize_fixture_doc(str(TIMEZONE_IDS[1:]))
387+
@pytest.fixture(params=TIMEZONES[1:], ids=TIMEZONE_IDS[1:])
383388
def tz_aware_fixture(request):
384389
"""
385390
Fixture for trying explicit timezones: {0}
386391
"""
387392
return request.param
388393

389394

395+
# Generate cartesian product of tz_aware_fixture:
396+
tz_aware_fixture2 = tz_aware_fixture
397+
398+
390399
# ----------------------------------------------------------------
391400
# Dtypes
401+
402+
392403
UNSIGNED_INT_DTYPES = ["uint8", "uint16", "uint32", "uint64"]
393404
UNSIGNED_EA_INT_DTYPES = ["UInt8", "UInt16", "UInt32", "UInt64"]
394405
SIGNED_INT_DTYPES = [int, "int8", "int16", "int32", "int64"]
@@ -400,16 +411,16 @@ def tz_aware_fixture(request):
400411
COMPLEX_DTYPES = [complex, "complex64", "complex128"]
401412
STRING_DTYPES = [str, 'str', 'U']
402413

403-
DATETIME_DTYPES = ['datetime64[ns]', 'M8[ns]']
404-
TIMEDELTA_DTYPES = ['timedelta64[ns]', 'm8[ns]']
414+
DATETIME64_DTYPES = ['datetime64[ns]', 'M8[ns]']
415+
TIMEDELTA64_DTYPES = ['timedelta64[ns]', 'm8[ns]']
405416

406417
BOOL_DTYPES = [bool, 'bool']
407418
BYTES_DTYPES = [bytes, 'bytes']
408419
OBJECT_DTYPES = [object, 'object']
409420

410421
ALL_REAL_DTYPES = FLOAT_DTYPES + ALL_INT_DTYPES
411422
ALL_NUMPY_DTYPES = (ALL_REAL_DTYPES + COMPLEX_DTYPES + STRING_DTYPES
412-
+ DATETIME_DTYPES + TIMEDELTA_DTYPES + BOOL_DTYPES
423+
+ DATETIME64_DTYPES + TIMEDELTA64_DTYPES + BOOL_DTYPES
413424
+ OBJECT_DTYPES + BYTES_DTYPES * PY3) # bytes only for PY3
414425

415426

@@ -424,6 +435,46 @@ def string_dtype(request):
424435
return request.param
425436

426437

438+
@pytest.fixture(params=BYTES_DTYPES)
439+
def bytes_dtype(request):
440+
"""Parametrized fixture for bytes dtypes.
441+
442+
* bytes
443+
* 'bytes'
444+
"""
445+
return request.param
446+
447+
448+
@pytest.fixture(params=OBJECT_DTYPES)
449+
def object_dtype(request):
450+
"""Parametrized fixture for object dtypes.
451+
452+
* object
453+
* 'object'
454+
"""
455+
return request.param
456+
457+
458+
@pytest.fixture(params=DATETIME64_DTYPES)
459+
def datetime64_dtype(request):
460+
"""Parametrized fixture for datetime/timedelta dtypes.
461+
462+
* 'datetime64[ns]'
463+
* 'M8[ns]'
464+
"""
465+
return request.param
466+
467+
468+
@pytest.fixture(params=TIMEDELTA64_DTYPES)
469+
def timedelta64_dtype(request):
470+
"""Parametrized fixture for datetime/timedelta dtypes.
471+
472+
* 'timedelta64[ns]'
473+
* 'm8[ns]'
474+
"""
475+
return request.param
476+
477+
427478
@pytest.fixture(params=FLOAT_DTYPES)
428479
def float_dtype(request):
429480
"""

0 commit comments

Comments
 (0)