Author onealj
Recipients onealj, stefan.richthofer
Date 2017-02-27.08:32:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This looks like an easy enough bug for a first-time contributor.
    public static PyString __doc__ = new PyString(
        "This module provides the components needed to build your own\n"+
        "__import__ function.  Undocumented functions are obsolete.\n"

    public static final PyString __doc__ = new PyString("Weak-reference support module.");

A strategy to write a unit test for this:
* Monkey-patch the pager target, pydoc.pager, so that we can capture the text that is sent to the pager (pipe to less/more or stdout). Pass text through pydoc.plain to strip bold markup bytes to make unit tests more readable.

# Back up global variables so they can be restored at the exit of the unit test
# Assume this unit test is executed atomically or wrap it in a lock.
@BeforeClass {
    import pydoc
    defaultpager = pydoc.pager

# Monkey-patch the pager target
# Basically the same as pydoc.plainpager, but capturing the output to StringIO rather than stdout)
@Before {
    out = StringIO.StringIO()
    stringiopager = lambda text: out.write(pydoc.plain(text))
    pydoc.pager = stringiopager

# Run the unit test

# Compare the output
    assertEquals(expectedText, out.getvalue())
    # We expect out.getvalue() to contain the text from _imp.__doc__ if we ignore whitespace. This currently fails.

# Cleanup and undo the monkey-patching
@After {
@AfterClass {
    pydoc.pager = defaultpager
Date User Action Args
2017-02-27 08:32:28onealjsetmessageid: <>
2017-02-27 08:32:28onealjsetrecipients: + onealj, stefan.richthofer
2017-02-27 08:32:28onealjlinkissue2545 messages
2017-02-27 08:32:27onealjcreate