test_formatting.py
This file
Path
tests/test_formatting.py
147 lines · 3.5 KiB · Python
Last changed by
Merge pull request #359 from markbt/help-formattingMarkus Unterwaditzerbefore adoption8056132
History of this fileTake it
The walk stopped after 200 commits: lines older than 5cae326 point at it.
Merge pull request #110 from krockode/patch-1Armin Ronacherbefore adoption5cae326
lines 1–50why, one step back1# -*- coding: utf-8 -*-2import click345def test_basic_functionality(runner):6 @click.command()7 def cli():8 """First paragraph.910 This is a very long second11 paragraph and not correctly12 wrapped but it will be rewrapped.1314 \b15 This is16 a paragraph17 without rewrapping.1819 \b20 121 222 32324 And this is a paragraph25 that will be rewrapped again.26 """2728 result = runner.invoke(cli, ['--help'], terminal_width=60)29 assert not result.exception30 assert result.output.splitlines() == [31 'Usage: cli [OPTIONS]',32 '',33 ' First paragraph.',34 '',35 ' This is a very long second paragraph and not correctly',36 ' wrapped but it will be rewrapped.',37 '',38 ' This is',39 ' a paragraph',40 ' without rewrapping.',41 '',42 ' 1',43 ' 2',44 ' 3',45 '',46 ' And this is a paragraph that will be rewrapped again.',47 '',48 'Options:',49 ' --help Show this message and exit.',50 ]Merge pull request #240 from sjagoe/fix-help-wrappingArmin Ronacherbefore adoptionc2c2bac
lines 51–74why, one step back515253def test_wrapping_long_options_strings(runner):54 @click.group()55 def cli():56 """Top level command57 """5859 @cli.group()60 def a_very_long():61 """Second level62 """6364 @a_very_long.command()65 @click.argument('first')66 @click.argument('second')67 @click.argument('third')68 @click.argument('fourth')69 @click.argument('fifth')70 @click.argument('sixth')71 def command():72 """A command.73 """74Merge pull request #359 from markbt/help-formattingMarkus Unterwaditzerbefore adoption8056132
line 75why, one step back75 # 54 is chosen as a length where the second line is one characterMerge pull request #240 from sjagoe/fix-help-wrappingArmin Ronacherbefore adoptionc2c2bac
lines 76–83why, one step back76 # longer than the maximum length.77 result = runner.invoke(cli, ['a_very_long', 'command', '--help'],78 terminal_width=54)79 assert not result.exception80 assert result.output.splitlines() == [81 'Usage: cli a_very_long command [OPTIONS] FIRST SECOND',82 ' THIRD FOURTH FIFTH',83 ' SIXTH',Merge pull request #359 from markbt/help-formattingMarkus Unterwaditzerbefore adoption8056132
lines 84–120why, one step back84 '',85 ' A command.',86 '',87 'Options:',88 ' --help Show this message and exit.',89 ]909192def test_wrapping_long_command_name(runner):93 @click.group()94 def cli():95 """Top level command96 """9798 @cli.group()99 def a_very_very_very_long():100 """Second level101 """102103 @a_very_very_very_long.command()104 @click.argument('first')105 @click.argument('second')106 @click.argument('third')107 @click.argument('fourth')108 @click.argument('fifth')109 @click.argument('sixth')110 def command():111 """A command.112 """113114 result = runner.invoke(cli, ['a_very_very_very_long', 'command', '--help'],115 terminal_width=54)116 assert not result.exception117 assert result.output.splitlines() == [118 'Usage: cli a_very_very_very_long command ',119 ' [OPTIONS] FIRST SECOND THIRD FOURTH FIFTH',120 ' SIXTH',Merge pull request #240 from sjagoe/fix-help-wrappingArmin Ronacherbefore adoptionc2c2bac
lines 121–126why, one step back121 '',122 ' A command.',123 '',124 'Options:',125 ' --help Show this message and exit.',126 ]Merge branch '4.x-maintenance'Markus Unterwaditzerbefore adoption099b549
lines 127–147why, one step back127128129def test_formatting_empty_help_lines(runner):130 @click.command()131 def cli():132 """Top level command133134 """135136 result = runner.invoke(cli, ['--help'])137 assert not result.exception138 assert result.output.splitlines() == [139 'Usage: cli [OPTIONS]',140 '',141 ' Top level command',142 '',143 '',144 '',145 'Options:',146 ' --help Show this message and exit.',147 ]