@pytest.mark.skipif(str(u'not six.PY2'))
def test_color_print_no_default_encoding():
 orig_func = locale.getpreferredencoding
 locale.getpreferredencoding = (lambda : u'')
 try:
  stream = io.StringIO()
  console.color_print('\xe2\x98\x83', u'white', file=stream)
  assert (stream.getvalue() == u'\u2603\n')
  stream = io.StringIO()
  console.color_print('\xcd\xef', u'red', file=stream)
  assert (stream.getvalue() == u'\xcd\xef\n')
 finally:
  locale.getpreferredencoding = orig_func

@ pytest . mark . skipif ( str ( u'not six.PY2' ) ) def test_color_print_no_default_encoding ( ) : orig_func = locale . getpreferredencoding locale . getpreferredencoding = ( lambda : u'' ) try : stream = io . StringIO ( ) console . color_print ( '\xe2\x98\x83' , u'white' , file = stream ) assert ( stream . getvalue ( ) == u'\u2603\n' ) stream = io . StringIO ( ) console . color_print ( '\xcd\xef' , u'red' , file = stream ) assert ( stream . getvalue ( ) == u'\xcd\xef\n' ) finally : locale . getpreferredencoding = orig_func
regression test for #1244 in some environments locale .