diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-06-30 15:55:43 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-06-30 15:55:43 +0200 |
commit | e6c910e9537d405a11377a478556731b4eaec419 (patch) | |
tree | 2c8e4faafe9da3f52de933940ff0f1e085ea6274 /Lib/test/test_pydoc.py | |
parent | dc9b1ea02eba907ae48cea682a49c5df34d0e19e (diff) | |
download | cpython-git-e6c910e9537d405a11377a478556731b4eaec419.tar.gz |
Issue #12451: pydoc.synopsis() now reads the encoding cookie if available, to
read the Python script from the right encoding.
Diffstat (limited to 'Lib/test/test_pydoc.py')
-rw-r--r-- | Lib/test/test_pydoc.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index 08ba86e697..a8f9fbfc5f 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -16,7 +16,7 @@ from io import StringIO from collections import namedtuple from contextlib import contextmanager from test.support import TESTFN, forget, rmtree, EnvironmentVarGuard, \ - reap_children, captured_output, captured_stdout + reap_children, captured_output, captured_stdout, unlink from test import pydoc_mod @@ -389,6 +389,17 @@ class PydocDocTest(unittest.TestCase): self.assertIn('_replace', helptext) self.assertIn('_asdict', helptext) + def test_synopsis(self): + self.addCleanup(unlink, TESTFN) + for encoding in ('ISO-8859-1', 'UTF-8'): + with open(TESTFN, 'w', encoding=encoding) as script: + if encoding != 'UTF-8': + print('#coding: {}'.format(encoding), file=script) + print('"""line 1: h\xe9', file=script) + print('line 2: hi"""', file=script) + synopsis = pydoc.synopsis(TESTFN, {}) + self.assertEqual(synopsis, 'line 1: h\xe9') + class TestDescriptions(unittest.TestCase): |