|
16 | 16 | from collections import namedtuple |
17 | 17 | from contextlib import contextmanager |
18 | 18 | from test.support import TESTFN, forget, rmtree, EnvironmentVarGuard, \ |
19 | | - reap_children, captured_output, captured_stdout |
| 19 | + reap_children, captured_output, captured_stdout, unlink |
20 | 20 |
|
21 | 21 | from test import pydoc_mod |
22 | 22 |
|
@@ -389,6 +389,17 @@ def test_namedtuple_public_underscore(self): |
389 | 389 | self.assertIn('_replace', helptext) |
390 | 390 | self.assertIn('_asdict', helptext) |
391 | 391 |
|
| 392 | + def test_synopsis(self): |
| 393 | + self.addCleanup(unlink, TESTFN) |
| 394 | + for encoding in ('ISO-8859-1', 'UTF-8'): |
| 395 | + with open(TESTFN, 'w', encoding=encoding) as script: |
| 396 | + if encoding != 'UTF-8': |
| 397 | + print('#coding: {}'.format(encoding), file=script) |
| 398 | + print('"""line 1: h\xe9', file=script) |
| 399 | + print('line 2: hi"""', file=script) |
| 400 | + synopsis = pydoc.synopsis(TESTFN, {}) |
| 401 | + self.assertEqual(synopsis, 'line 1: h\xe9') |
| 402 | + |
392 | 403 |
|
393 | 404 | class TestDescriptions(unittest.TestCase): |
394 | 405 |
|
|
0 commit comments