def test_print_utf8_string_to_ascii_stdout(self):
        # Change stdout's encoding to ascii:
        default_stdout = sys.stdout
        sys.stdout = codecs.getwriter("ascii")(default_stdout)

        # Show that the default print fails to print a utf-8 string to an ascii stdout.
        # See http://nedbatchelder.com/text/unipain/unipain.html
        utf8_string = "Tschüß!"
        with self.assertRaises(UnicodeDecodeError):
            print(utf8_string)

        # Show that our _print is able to do it:
        gcw._print(utf8_string)

        # Restore stdout's encoding (to utf-8):
        sys.stdout = default_stdout
    def test_print_utf8_string_to_ascii_stdout(self):
        # Change stdout's encoding to ascii:
        default_stdout = sys.stdout
        sys.stdout = codecs.getwriter("ascii")(default_stdout)

        # Show that the default print fails to print a utf-8 string to an ascii stdout.
        # See http://nedbatchelder.com/text/unipain/unipain.html
        utf8_string = "Tschüß!"
        with self.assertRaises(UnicodeDecodeError):
            print(utf8_string)

        # Show that our _print is able to do it:
        gcw._print(utf8_string)

        # Restore stdout's encoding (to utf-8):
        sys.stdout = default_stdout
 def test_print_utf8_string(self):
     utf8_string = "Tschüß!"
     gcw._print(utf8_string)  # shouldn't raise
 def test_print_utf8_string(self):
     utf8_string = "Tschüß!"
     gcw._print(utf8_string) # shouldn't raise