Ticket #1601: 1601v3.patch

File 1601v3.patch, 2.3 KB (added by Stephen Solis, 9 years ago)

Applied review suggestions.

  • twisted/test/test_usage.py

     
    1 
    21# Copyright (c) Twisted Matrix Laboratories.
    32# See LICENSE for details.
    43
     
    348347        self.failUnlessIdentical(oBar.subOptions.parent, oBar)
    349348
    350349
     350class GetUsageOptions(usage.Options):
     351    longdesc = ("\nA test documentation string.\n"
     352                "This line has more than 80 characters-"
     353                "PADDINGXXPADDINGXXPADDINGXXPADDINGXXPADDINGXXPADDINGXX\n")
     354
     355
    351356class HelpStringTest(unittest.TestCase):
    352357    def setUp(self):
    353358        """
     
    379384        self.failUnless(len(lines) > 0)
    380385        self.failUnless(lines[0].find("flagallicious") >= 0)
    381386
     387    def test_longdescNotWrapped(self):
     388        """
     389        getUsage does not wrap lines in longdesc.
     390        """
     391        opt = GetUsageOptions()
     392        opt.getUsage(width=80)
     393        self.assertTrue(len(opt.longdesc.splitlines()[2]) > 80)
    382394
     395
    383396class PortCoerceTestCase(unittest.TestCase):
    384397    """
    385398    Test the behavior of L{usage.portCoerce}.
     
    583596                action = cls(None)
    584597            self.assertRaises(NotImplementedError, action._shellCode,
    585598                              None, "bad_shell_type")
    586 
    587 class GetUsageOptions(usage.Options):
    588     longdesc = """
    589 A test documentation string.
    590 This line has more than 80 characters-PADDINGXXPADDINGXXPADDINGXXPADDINGXXPADDINGXXPADDINGXX
    591 """
    592 
    593 class 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' + longdesc.strip() + '\n')
     537            longdesc = '\n' + longdesc.strip() + '\n'
    538538
    539539        if optDicts:
    540540            chunks = docMakeChunks(optDicts, width)