Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Basthon
Basthon Kernel
Commits
463c4811
Commit
463c4811
authored
Oct 08, 2022
by
Romain Casati
Browse files
Python 3 Old: fix prompt in help.
parent
9312e9f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
packages/kernel-python3-old/src/basthon/_patch_builtins.py
View file @
463c4811
...
...
@@ -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
():
"""
...
...
tests/test_python3-old_patch_builtins.py
View file @
463c4811
...
...
@@ -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
(
"""
...
...
tests/test_python3_10_patch_builtins.py
View file @
463c4811
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment