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 ''')
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:])
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:])