8000 bpo-29854: test_readline logs versions in verbose mode by vstinner · Pull Request #2619 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-29854: test_readline logs versions in verbose mode #2619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loadi 8000 ng
Diff view
Diff view
20 changes: 18 additions & 2 deletions Lib/test/test_readline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,29 @@
import sys
import tempfile
import unittest
from test.support import import_module, unlink, temp_dir, TESTFN
from test.support import import_module, unlink, temp_dir, TESTFN, verbose
from test.support.script_helper import assert_python_ok

# Skip tests if there is no readline module
readline = import_module('readline')

is_editline = readline.__doc__ and "libedit" in readline.__doc__
if hasattr(readline, "_READLINE_LIBRARY_VERSION"):
is_editline = ("EditLine wrapper" in readline._READLINE_LIBRARY_VERSION)
else:
is_editline = (readline.__doc__ and "libedit" in readline.__doc__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like duplicating the horrible doc check, and adding a new incompatible check for the same thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like duplicating the horrible doc check, and adding a new incompatible check for the same thing.

IMHO such enhancement would deserves its own PR ;-)



def setUpModule():
if verbose:
# Python implementations other than CPython may not have
# these private attributes
if hasattr(readline, "_READLINE_VERSION"):
print(f"readline version: {readline._READLINE_VERSION:#x}")
print(f"readline runtime version: {readline._READLINE_RUNTIME_VERSION:#x}")
if hasattr(readline, "_READLINE_LIBRARY_VERSION"):
print(f"readline library version: {readline._READLINE_LIBRARY_VERSION!r}")
print(f"use libedit emulation? {is_editline}")


@unittest.skipUnless(hasattr(readline, "clear_history"),
"The history update test cannot be run because the "
Expand Down
1 change: 1 addition & 0 deletions Modules/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,7 @@ PyInit_readline(void)

PyModule_AddIntConstant(m, "_READLINE_VERSION", RL_READLINE_VERSION);
PyModule_AddIntConstant(m, "_READLINE_RUNTIME_VERSION", rl_readline_version);
PyModule_AddStringConstant(m, "_READLINE_LIBRARY_VERSION", rl_library_version);

return m;
}
0