summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-19 17:15:50 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-19 17:15:50 (GMT)
commit5b08b4d230d95fe6a0b24dc45463e785a27fecd2 (patch)
tree588fa0dedec808ba6dfed25c2a811eda0d85c58a
parent1802d3f3888b374b8d44470156a98081697a6280 (diff)
downloadcpython-5b08b4d230d95fe6a0b24dc45463e785a27fecd2.zip
cpython-5b08b4d230d95fe6a0b24dc45463e785a27fecd2.tar.gz
cpython-5b08b4d230d95fe6a0b24dc45463e785a27fecd2.tar.bz2
Oops, add the new test_log.py for distutils test suite (missing part of r81359)
-rw-r--r--Lib/distutils/tests/test_log.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/distutils/tests/test_log.py b/Lib/distutils/tests/test_log.py
new file mode 100644
index 0000000..d35de34
--- /dev/null
+++ b/Lib/distutils/tests/test_log.py
@@ -0,0 +1,36 @@
+"""Tests for distutils.log"""
+
+import sys
+import unittest
+from tempfile import NamedTemporaryFile
+
+from distutils import log
+
+class TestLog(unittest.TestCase):
+ def test_non_ascii(self):
+ # Issue #8663: test that non-ASCII text is escaped with
+ # backslashreplace error handler (stream use ASCII encoding and strict
+ # error handler)
+ old_stdout = sys.stdout
+ old_stderr = sys.stderr
+ try:
+ log.set_threshold(log.DEBUG)
+ with NamedTemporaryFile(mode="w+", encoding='ascii') as stdout, \
+ NamedTemporaryFile(mode="w+", encoding='ascii') as stderr:
+ sys.stdout = stdout
+ sys.stderr = stderr
+ log.debug("debug:\xe9")
+ log.fatal("fatal:\xe9")
+ stdout.seek(0)
+ self.assertEquals(stdout.read().rstrip(), "debug:\\xe9")
+ stderr.seek(0)
+ self.assertEquals(stderr.read().rstrip(), "fatal:\\xe9")
+ finally:
+ sys.stdout = old_stdout
+ sys.stderr = old_stderr
+
+def test_suite():
+ return unittest.makeSuite(TestLog)
+
+if __name__ == "__main__":
+ unittest.main(defaultTest="test_suite")