raise
print(exc)
else:
- output.write(render_doc(thing, title, forceload, plaintext))
+ try:
+ s = render_doc(thing, title, forceload, plaintext)
+ except ImportError as exc:
+ s = str(exc)
+ output.write(s)
def writedoc(thing, forceload=0):
"""Write HTML documentation to a file in the current directory."""
# Testing that the subclasses section does not appear
self.assertNotIn('Built-in subclasses', text)
+ def test_fail_help_output_redirect(self):
+ with StringIO() as buf:
+ helper = pydoc.Helper(output=buf)
+ helper.help("abd")
+ expected = missing_pattern % "abd"
+ self.assertEqual(expected, buf.getvalue().strip().replace('\n', os.linesep))
+
@unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(),
'trace function introduces __locals__ unexpectedly')
@requires_docstrings