summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_compileall.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2010-03-21 22:02:42 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2010-03-21 22:02:42 (GMT)
commite96ac3a33a154b454159c903cfcfcac5ed56215e (patch)
treed1d40adb030bafecaf679f7c9290a56d72254add /Lib/test/test_compileall.py
parent1d6af707cfac6406feb5c82656bb8f313bfcb696 (diff)
downloadcpython-e96ac3a33a154b454159c903cfcfcac5ed56215e.zip
cpython-e96ac3a33a154b454159c903cfcfcac5ed56215e.tar.gz
cpython-e96ac3a33a154b454159c903cfcfcac5ed56215e.tar.bz2
Merged revisions 78991-78992,78994 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r78991 | martin.v.loewis | 2010-03-16 12:03:13 +0100 (Di, 16 Mär 2010) | 9 lines Merged revisions 78976 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78976 | martin.v.loewis | 2010-03-15 14:00:17 +0100 (Mo, 15 Mär 2010) | 1 line Issue #6716: Quote -x arguments of compileall in MSI installer. ........ ................ r78992 | martin.v.loewis | 2010-03-16 14:19:21 +0100 (Di, 16 Mär 2010) | 2 lines Issue #6716/2: Backslash-replace error output in compilall. ................ r78994 | martin.v.loewis | 2010-03-16 17:19:47 +0100 (Di, 16 Mär 2010) | 1 line Issue #6716/3: Exclude 2to3 tests from compileall. ................
Diffstat (limited to 'Lib/test/test_compileall.py')
-rw-r--r--Lib/test/test_compileall.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py
index 49b6448..fe1dcf7 100644
--- a/Lib/test/test_compileall.py
+++ b/Lib/test/test_compileall.py
@@ -1,3 +1,4 @@
+import sys
import compileall
import imp
import os
@@ -9,6 +10,7 @@ import tempfile
import time
from test import support
import unittest
+import io
class CompileallTests(unittest.TestCase):
@@ -55,8 +57,30 @@ class CompileallTests(unittest.TestCase):
self.recreation_check(b'\0\0\0\0')
+class EncodingTest(unittest.TestCase):
+ 'Issue 6716: compileall should escape source code when printing errors to stdout.'
+
+ def setUp(self):
+ self.directory = tempfile.mkdtemp()
+ self.source_path = os.path.join(self.directory, '_test.py')
+ with open(self.source_path, 'w', encoding='utf-8') as file:
+ file.write('# -*- coding: utf-8 -*-\n')
+ file.write('print u"\u20ac"\n')
+
+ def tearDown(self):
+ shutil.rmtree(self.directory)
+
+ def test_error(self):
+ try:
+ orig_stdout = sys.stdout
+ sys.stdout = io.TextIOWrapper(io.BytesIO(),encoding='ascii')
+ compileall.compile_dir(self.directory)
+ finally:
+ sys.stdout = orig_stdout
+
def test_main():
- support.run_unittest(CompileallTests)
+ support.run_unittest(CompileallTests,
+ EncodingTest)
if __name__ == "__main__":