Commit 463c4811 authored by Romain Casati's avatar Romain Casati
Browse files

Python 3 Old: fix prompt in help.

parent 9312e9f5
......@@ -44,6 +44,8 @@ def patch_help():
it uses a class called ModuleScanner to list packages.
this class first looks at sys.builtin_module_names then in pkgutil.
we fake sys.builtin_module_names in order to get it right
We also fall back to the plainpager in order to avoid prompt input.
"""
_default_help = pydoc.help
......@@ -58,6 +60,13 @@ def patch_help():
pydoc.help = _patched_help
# pydoc.getpager default to pydoc.plainpager
def getpager():
return pydoc.plainpager
getpager.__doc__ = pydoc.getpager.__doc__
pydoc.getpager = getpager
def patch_six():
"""
......
......@@ -18,13 +18,17 @@ def test_patch_input(selenium_py3old):
assert result == "42"
def test_patch_modules(selenium_py3old):
def test_patch_help(selenium_py3old):
data = selenium_py3old.run_basthon("help('modules')")
assert 'result' not in data['result'] and data['stderr'] == ""
text = data['stdout']
target = read_and_backup(Path(__file__).parent / 'data' / 'python3-old_modules.txt', text)
assert text == target
data = selenium_py3old.run_basthon("help(str)")
assert 'result' not in data['result'] and data['stderr'] == ""
assert len(data['stdout']) == 14664
def test_patch_six(selenium_py3old):
data = selenium_py3old.run_basthon("""
......
......@@ -28,7 +28,7 @@ int(f("How old are you?"))
assert result == "42"
def test_patch_modules(selenium_py3):
def test_patch_help(selenium_py3):
# importing pkg_resources (setuptools) before using help to avoid warning
# 'Distutils was imported before Setuptools'
# TODO: find a way to import setuptools before using help
......@@ -40,3 +40,7 @@ def test_patch_modules(selenium_py3):
text = data['stdout']
target = read_and_backup(Path(__file__).parent / 'data' / 'python3_modules.txt', text)
assert text == target
data = selenium_py3.run_basthon("help(str)")
assert 'result' not in data['result'] and data['stderr'] == ""
assert len(data['stdout']) == 15214
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment