Back to index

python3.2  3.2.2
Public Member Functions
distutils.tests.test_log.TestLog Class Reference

List of all members.

Public Member Functions

def test_non_ascii

Detailed Description

Definition at line 10 of file test_log.py.


Member Function Documentation

Definition at line 11 of file test_log.py.

00011 
00012     def test_non_ascii(self):
00013         # Issue #8663: test that non-ASCII text is escaped with
00014         # backslashreplace error handler (stream use ASCII encoding and strict
00015         # error handler)
00016         old_stdout = sys.stdout
00017         old_stderr = sys.stderr
00018         try:
00019             log.set_threshold(log.DEBUG)
00020             with NamedTemporaryFile(mode="w+", encoding='ascii') as stdout, \
00021                  NamedTemporaryFile(mode="w+", encoding='ascii') as stderr:
00022                 sys.stdout = stdout
00023                 sys.stderr = stderr
00024                 log.debug("debug:\xe9")
00025                 log.fatal("fatal:\xe9")
00026                 stdout.seek(0)
00027                 self.assertEqual(stdout.read().rstrip(), "debug:\\xe9")
00028                 stderr.seek(0)
00029                 self.assertEqual(stderr.read().rstrip(), "fatal:\\xe9")
00030         finally:
00031             sys.stdout = old_stdout
00032             sys.stderr = old_stderr

Here is the call graph for this function:


The documentation for this class was generated from the following file: