Ticket #1601: 1601v2.patch

File 1601v2.patch, 1.6 KB (added by Stephen Solis, 9 years ago)

Added unit test and news file

  • twisted/test/test_usage.py

     
     1
    12# Copyright (c) Twisted Matrix Laboratories.
    23# See LICENSE for details.
    34
     
    582583                action = cls(None)
    583584            self.assertRaises(NotImplementedError, action._shellCode,
    584585                              None, "bad_shell_type")
     586
     587class GetUsageOptions(usage.Options):
     588    longdesc = """
     589A test documentation string.
     590This line has more than 80 characters-PADDINGXXPADDINGXXPADDINGXXPADDINGXXPADDINGXXPADDINGXX
     591"""
     592
     593class GetUsageTestCase(unittest.TestCase):
     594    """
     595    Test Options.getUsage for proper output.
     596    """
     597    def test_longdescNotWrapped(self):
     598        """
     599        Check that lines in longdesc are not wrapped.
     600        """
     601        opt = GetUsageOptions()
     602        opt.getUsage(width=80)
     603        self.assertGreater(len(opt.longdesc.splitlines()[2]), 80)
  • twisted/python/usage.py

     
    534534                longdesc = ''
    535535
    536536        if longdesc:
    537             longdesc = ('\n' +
    538                         '\n'.join(text.wordWrap(longdesc, width)).strip()
    539                         + '\n')
     537            longdesc = ('\n' + longdesc.strip() + '\n')
    540538
    541539        if optDicts:
    542540            chunks = docMakeChunks(optDicts, width)