Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4)

Unified Diff: Lib/test/test_pydoc.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_posix.py ('k') | Lib/test/test_raise.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_pydoc.py Tue Jul 26 09:37:46 2011 +0300
+++ b/Lib/test/test_pydoc.py Mon Jul 25 09:47:18 2011 -0400
@@ -15,12 +15,9 @@
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
-from test.script_helper import assert_python_ok
-from test.support import (
- TESTFN, forget, rmtree, EnvironmentVarGuard,
- reap_children, reap_threads, captured_output, captured_stdout, unlink
-)
from test import pydoc_mod
try:
@@ -202,14 +199,17 @@
# output pattern for module with bad imports
badimport_pattern = "problem in %s - ImportError: No module named %r"
-def run_pydoc(module_name, *args, **env):
+def run_pydoc(module_name, *args):
"""
Runs pydoc on the specified module. Returns the stripped
output of pydoc.
"""
- args = args + (module_name,)
- rc, out, err = assert_python_ok(pydoc.__file__, *args, **env)
- return out.strip()
+ cmd = [sys.executable, pydoc.__file__, " ".join(args), module_name]
+ try:
+ output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
+ return output.strip()
+ finally:
+ reap_children()
def get_pydoc_html(module):
"Returns pydoc generated output as html"
@@ -312,20 +312,19 @@
def newdirinpath(dir):
os.mkdir(dir)
sys.path.insert(0, dir)
- try:
- yield
- finally:
- sys.path.pop(0)
- rmtree(dir)
+ yield
+ sys.path.pop(0)
+ rmtree(dir)
- with newdirinpath(TESTFN):
+ with newdirinpath(TESTFN), EnvironmentVarGuard() as env:
+ env['PYTHONPATH'] = TESTFN
fullmodname = os.path.join(TESTFN, modname)
sourcefn = fullmodname + os.extsep + "py"
for importstring, expectedinmsg in testpairs:
with open(sourcefn, 'w') as f:
f.write("import {}\n".format(importstring))
try:
- result = run_pydoc(modname, PYTHONPATH=TESTFN).decode("ascii")
+ result = run_pydoc(modname).decode("ascii")
finally:
forget(modname)
expected = badimport_pattern % (modname, expectedinmsg)
@@ -396,17 +395,6 @@
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):
@@ -495,17 +483,13 @@
self.assertEqual(sorted(pydoc.Helper.keywords),
sorted(keyword.kwlist))
-@reap_threads
def test_main():
- try:
- test.support.run_unittest(PydocDocTest,
- TestDescriptions,
- PydocServerTest,
- PydocUrlHandlerTest,
- TestHelper,
- )
- finally:
- reap_children()
+ test.support.run_unittest(PydocDocTest,
+ TestDescriptions,
+ PydocServerTest,
+ PydocUrlHandlerTest,
+ TestHelper,
+ )
if __name__ == "__main__":
test_main()
« no previous file with comments | « Lib/test/test_posix.py ('k') | Lib/test/test_raise.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+