11import numpy as np
2- import pytest
3-
4- from pandas ._config import using_string_dtype
52
63from pandas import (
74 Categorical ,
@@ -77,17 +74,19 @@ def test_print_none_width(self):
7774 with option_context ("display.width" , None ):
7875 assert exp == repr (a )
7976
80- @pytest .mark .skipif (
81- using_string_dtype (),
82- reason = "Change once infer_string is set to True by default" ,
83- )
84- def test_unicode_print (self ):
77+ def test_unicode_print (self , using_infer_string ):
8578 c = Categorical (["aaaaa" , "bb" , "cccc" ] * 20 )
8679 expected = """\
8780 ['aaaaa', 'bb', 'cccc', 'aaaaa', 'bb', ..., 'bb', 'cccc', 'aaaaa', 'bb', 'cccc']
8881Length: 60
8982Categories (3, object): ['aaaaa', 'bb', 'cccc']"""
9083
84+ if using_infer_string :
85+ expected = expected .replace (
86+ "(3, object): ['aaaaa', 'bb', 'cccc']" ,
87+ "(3, str): [aaaaa, bb, cccc]" ,
88+ )
89+
9190 assert repr (c ) == expected
9291
9392 c = Categorical (["ああああ" , "いいいいい" , "ううううううう" ] * 20 )
@@ -96,6 +95,12 @@ def test_unicode_print(self):
9695Length: 60
9796Categories (3, object): ['ああああ', 'いいいいい', 'ううううううう']""" # noqa: E501
9897
98+ if using_infer_string :
99+ expected = expected .replace (
100+ "(3, object): ['ああああ', 'いいいいい', 'ううううううう']" ,
101+ "(3, str): [ああああ, いいいいい, ううううううう]" ,
102+ )
103+
99104 assert repr (c ) == expected
100105
101106 # unicode option should not affect to Categorical, as it doesn't care
@@ -106,6 +111,12 @@ def test_unicode_print(self):
106111Length: 60
107112Categories (3, object): ['ああああ', 'いいいいい', 'ううううううう']""" # noqa: E501
108113
114+ if using_infer_string :
115+ expected = expected .replace (
116+ "(3, object): ['ああああ', 'いいいいい', 'ううううううう']" ,
117+ "(3, str): [ああああ, いいいいい, ううううううう]" ,
118+ )
119+
109120 assert repr (c ) == expected
110121
111122 def test_categorical_repr (self ):
0 commit comments