Пример #1
0
    def test_basic(self):
        sec = HelpSection()
        sec.add_text('foo', False)
        sec.add_option('--foo', 'FOO', True)
        sec.add_text('bar', True)
        sec.add_option('--bar', 'BAR', False)
        self.assertEqual(sec.headers, [(False, 'foo'), (True, 'bar')])
        self.assertEqual(sec.options, [(True, '--foo', 'FOO'),
                                       (False, '--bar', 'BAR')])

        out = StringIO()
        sec.print(out, False, float('inf'))
        self.assertEqual(out.getvalue(), '''foo
  --bar  BAR
''')

        out = StringIO()
        sec.print(out, True, float('inf'))
        self.assertEqual(out.getvalue(), '''foo
bar
  --foo  FOO
  --bar  BAR
''')
Пример #2
0
    def test_basic(self):
        sec = HelpSection()
        sec.add_text('foo', False)
        sec.add_option('--foo', 'FOO', True)
        sec.add_text('bar', True)
        sec.add_option('--bar', 'BAR', False)
        self.assertEqual(sec.headers, [(False, 'foo'), (True, 'bar')])
        self.assertEqual(sec.options, [(True, '--foo', 'FOO'), (False, '--bar', 'BAR')])

        out = StringIO()
        sec.print(out, False, float('inf'))
        self.assertEqual(out.getvalue(), '''foo
  --bar  BAR
''')

        out = StringIO()
        sec.print(out, True, float('inf'))
        self.assertEqual(out.getvalue(), '''foo
bar
  --foo  FOO
  --bar  BAR
''')
Пример #3
0
    def test_print(self):
        sec = HelpSection()
        sec.add_option('--abcdefghijklmnopqrstuvwxyz',
                       'ABCDEFGHIJKLMNOPQRSTUVWXYZ', False)

        out = StringIO()
        sec.print(out, False, 80)
        self.assertEqual(
            out.getvalue(), '''
  --abcdefghijklmnopqrstuvwxyz
                    ABCDEFGHIJKLMNOPQRSTUVWXYZ
'''[1:])

        sec.add_option('--foo', 'FOO', False)
        sec.add_option('--frob', 'FROB', False)

        out = StringIO()
        sec.print(out, False, 80)
        self.assertEqual(
            out.getvalue(), '''
  --abcdefghijklmnopqrstuvwxyz
          ABCDEFGHIJKLMNOPQRSTUVWXYZ
  --foo   FOO
  --frob  FROB
'''[1:])

        out = StringIO()
        sec.print(out, False, float('inf'))
        self.assertEqual(
            out.getvalue(), '''
  --abcdefghijklmnopqrstuvwxyz  ABCDEFGHIJKLMNOPQRSTUVWXYZ
  --foo                         FOO
  --frob                        FROB
'''[1:])
Пример #4
0
    def test_print(self):
        sec = HelpSection()
        sec.add_option('--abcdefghijklmnopqrstuvwxyz',
                'ABCDEFGHIJKLMNOPQRSTUVWXYZ', False)

        out = StringIO()
        sec.print(out, False, 80)
        self.assertEqual(out.getvalue(), '''
  --abcdefghijklmnopqrstuvwxyz
                    ABCDEFGHIJKLMNOPQRSTUVWXYZ
'''[1:])

        sec.add_option('--foo', 'FOO', False)
        sec.add_option('--frob', 'FROB', False)

        out = StringIO()
        sec.print(out, False, 80)
        self.assertEqual(out.getvalue(), '''
  --abcdefghijklmnopqrstuvwxyz
          ABCDEFGHIJKLMNOPQRSTUVWXYZ
  --foo   FOO
  --frob  FROB
'''[1:])

        out = StringIO()
        sec.print(out, False, float('inf'))
        self.assertEqual(out.getvalue(), '''
  --abcdefghijklmnopqrstuvwxyz  ABCDEFGHIJKLMNOPQRSTUVWXYZ
  --foo                         FOO
  --frob                        FROB
'''[1:])