diff options
| author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-19 17:15:50 +0000 |
|---|---|---|
| committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-19 17:15:50 +0000 |
| commit | 727851619e008c1f44e79a60ddff41bb4ebf02b7 (patch) | |
| tree | 60c0bdfe858da2ec9bdb21522b3cce5d92ad5078 | |
| parent | b78e3623ca34400e29297da0409211a7d83728c6 (diff) | |
| download | python-setuptools-git-727851619e008c1f44e79a60ddff41bb4ebf02b7.tar.gz | |
Oops, add the new test_log.py for distutils test suite (missing part of r81359)
| -rw-r--r-- | tests/test_log.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_log.py b/tests/test_log.py new file mode 100644 index 00000000..d35de345 --- /dev/null +++ b/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") |
