1212from pandas .util import testing as tm
1313from pandas .util .testing import makeCustomDataframe as mkdf
1414
15+ from pandas .io .clipboard import clipboard_get , clipboard_set
1516from pandas .io .clipboard .exceptions import PyperclipException
1617
1718try :
@@ -30,8 +31,8 @@ def build_kwargs(sep, excel):
3031 return kwargs
3132
3233
33- @pytest .fixture (params = ['delims' , 'utf8' , 'string ' , 'long ' , 'nonascii ' ,
34- 'colwidth' , 'mixed' , 'float' , 'int' ])
34+ @pytest .fixture (params = ['delims' , 'utf8' , 'utf16 ' , 'string ' , 'long ' ,
35+ 'nonascii' , ' colwidth' , 'mixed' , 'float' , 'int' ])
3536def df (request ):
3637 data_type = request .param
3738
@@ -41,6 +42,10 @@ def df(request):
4142 elif data_type == 'utf8' :
4243 return pd .DataFrame ({'a' : ['µasd' , 'Ωœ∑´' ],
4344 'b' : ['øπ∆˚¬' , 'œ∑´®' ]})
45+ elif data_type == 'utf16' :
46+ return pd .DataFrame ({'a' : ['\U0001f44d \U0001f44d ' ,
47+ '\U0001f44d \U0001f44d ' ],
48+ 'b' : ['abc' , 'def' ]})
4449 elif data_type == 'string' :
4550 return mkdf (5 , 3 , c_idx_type = 's' , r_idx_type = 'i' ,
4651 c_idx_names = [None ], r_idx_names = [None ])
@@ -225,3 +230,14 @@ def test_invalid_encoding(self, df):
225230 @pytest .mark .parametrize ('enc' , ['UTF-8' , 'utf-8' , 'utf8' ])
226231 def test_round_trip_valid_encodings (self , enc , df ):
227232 self .check_round_trip_frame (df , encoding = enc )
233+
234+
235+ @pytest .mark .single
236+ @pytest .mark .clipboard
237+ @pytest .mark .skipif (not _DEPS_INSTALLED ,
238+ reason = "clipboard primitives not installed" )
239+ @pytest .mark .parametrize ('data' , [u'\U0001f44d ...' , u'Ωœ∑´...' , 'abcd...' ])
240+ def test_raw_roundtrip (data ):
241+ # PR #25040 wide unicode wasn't copied correctly on PY3 on windows
242+ clipboard_set (data )
243+ assert data == clipboard_get ()
0 commit comments