@@ -40,9 +40,10 @@ class ConstructorTests:
40
40
get_kwargs_from_breaks to the expected format.
41
41
"""
42
42
43
- # get_kwargs_from_breaks in TestFromTuples and TestClassconstructors just return
44
- # tuples of ints, so IntervalIndex can't know the original dtype was uint
45
- _use_dtype_in_test_constructor_uint = False
43
+ def _skip_test_constructor (self , dtype ):
44
+ # get_kwargs_from_breaks in TestFromTuples and TestClassconstructors just return
45
+ # tuples of ints, so IntervalIndex can't know the original dtype
46
+ return False , ""
46
47
47
48
@pytest .mark .parametrize (
48
49
"breaks" ,
@@ -60,9 +61,13 @@ class ConstructorTests:
60
61
@pytest .mark .parametrize ("use_dtype" , [True , False ])
61
62
def test_constructor (self , constructor , breaks , closed , name , use_dtype ):
62
63
breaks_dtype = getattr (breaks , "dtype" , "int64" )
64
+
65
+ skip , skip_msg = self ._skip_test_constructor (breaks_dtype )
66
+ if skip :
67
+ pytest .skip (skip_msg )
68
+
63
69
result_kwargs = self .get_kwargs_from_breaks (breaks , closed )
64
- is_uint = is_unsigned_integer_dtype (breaks_dtype )
65
- if use_dtype or (self ._use_dtype_in_test_constructor_uint and is_uint ):
70
+ if use_dtype :
66
71
result_kwargs ["dtype" ] = IntervalDtype (breaks_dtype , closed = closed )
67
72
68
73
result = constructor (closed = closed , name = name , ** result_kwargs )
@@ -307,7 +312,11 @@ def test_left_right_dont_share_data(self):
307
312
class TestFromTuples (ConstructorTests ):
308
313
"""Tests specific to IntervalIndex.from_tuples"""
309
314
310
- _use_dtype_in_test_constructor_uint = True
315
+ def _skip_test_constructor (self , dtype ):
316
+ if is_unsigned_integer_dtype (dtype ):
317
+ return True , "tuples don't have a dtype"
318
+ else :
319
+ return False , ""
311
320
312
321
@pytest .fixture
313
322
def constructor (self ):
@@ -356,7 +365,13 @@ def test_na_tuples(self):
356
365
class TestClassConstructors (ConstructorTests ):
357
366
"""Tests specific to the IntervalIndex/Index constructors"""
358
367
359
- _use_dtype_in_test_constructor_uint = True
368
+ def _skip_test_constructor (self , dtype ):
369
+ # get_kwargs_from_breaks in TestFromTuples and TestClassconstructors just return
370
+ # tuples of ints, so IntervalIndex can't know the original dtype
371
+ if is_unsigned_integer_dtype (dtype ):
372
+ return True , "tuples don't have a dtype"
373
+ else :
374
+ return False , ""
360
375
361
376
@pytest .fixture (
362
377
params = [IntervalIndex , partial (Index , dtype = "interval" )],
0 commit comments