@@ -454,11 +454,21 @@ def test_constructor_dtype_and_others_raises(self):
454
454
with tm .assert_raises_regex (ValueError , "Cannot" ):
455
455
Categorical (['a' , 'b' ], ordered = False , dtype = dtype )
456
456
457
- def test_constructor_str_category (self ):
458
- result = Categorical (['a' , 'b' ], dtype = 'category' )
459
- expected = Categorical (['a' , 'b' ])
457
+ @pytest .mark .parametrize ('categories' , [
458
+ None , ['a' , 'b' ], ['a' , 'c' ],
459
+ ])
460
+ @pytest .mark .parametrize ('ordered' , [True , False ])
461
+ def test_constructor_str_category (self , categories , ordered ):
462
+ result = Categorical (['a' , 'b' ], categories = categories ,
463
+ ordered = ordered , dtype = 'category' )
464
+ expected = Categorical (['a' , 'b' ], categories = categories ,
465
+ ordered = ordered )
460
466
tm .assert_categorical_equal (result , expected )
461
467
468
+ def test_constructor_str_unknown (self ):
469
+ with tm .assert_raises_regex (ValueError , "Unknown `dtype`" ):
470
+ Categorical ([1 , 2 ], dtype = "foo" )
471
+
462
472
def test_from_codes (self ):
463
473
464
474
# too few categories
0 commit comments