Skip to content

Commit

Permalink
tests: Move tests to correct TestCase
Browse files Browse the repository at this point in the history
Non-group-related tests shouldn't be in GroupTestCase

Signed-off-by: Stephen Finucane <[email protected]>
  • Loading branch information
stephenfin committed Jan 27, 2022
1 parent 42cc68c commit d53cd26
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions tests/test_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,52 @@ def foobar():
'\n'.join(output),
)

def test_no_line_wrapping_epilog(self):
r"""Validate behavior of the \b character in an epilog."""

@click.command(
epilog="""
An epilog containing pre-wrapped text.
\b
This is
a paragraph
without rewrapping.
And this is a paragraph
that will be rewrapped again.
"""
)
def foobar():
"""A sample command."""

ctx = click.Context(foobar, info_name='foobar')
output = list(ext._format_command(ctx, nested='short'))

self.assertEqual(
textwrap.dedent(
"""
A sample command.
.. program:: foobar
.. code-block:: shell
foobar [OPTIONS]
An epilog containing pre-wrapped text.
| This is
| a paragraph
| without rewrapping.
And this is a paragraph
that will be rewrapped again.
"""
).lstrip(),
'\n'.join(output),
)


class GroupTestCase(unittest.TestCase):
"""Validate basic ``click.Group`` instances."""
Expand Down Expand Up @@ -461,52 +507,6 @@ def cli():
'\n'.join(output),
)

def test_no_line_wrapping_epilog(self):
r"""Validate behavior of the \b character in an epilog."""

@click.command(
epilog="""
An epilog containing pre-wrapped text.
\b
This is
a paragraph
without rewrapping.
And this is a paragraph
that will be rewrapped again.
"""
)
def foobar():
"""A sample command."""

ctx = click.Context(foobar, info_name='foobar')
output = list(ext._format_command(ctx, nested='short'))

self.assertEqual(
textwrap.dedent(
"""
A sample command.
.. program:: foobar
.. code-block:: shell
foobar [OPTIONS]
An epilog containing pre-wrapped text.
| This is
| a paragraph
| without rewrapping.
And this is a paragraph
that will be rewrapped again.
"""
).lstrip(),
'\n'.join(output),
)


class NestedCommandsTestCase(unittest.TestCase):
"""Validate ``click.Command`` instances inside ``click.Group`` instances."""
Expand Down

0 comments on commit d53cd26

Please sign in to comment.