@@ -356,8 +356,60 @@ def foobar():
356
356
'\n ' .join (output ),
357
357
)
358
358
359
- def test_no_line_wrapping_epilog (self ):
360
- r"""Validate behavior of the \b character in an epilog."""
359
+ @unittest .skipIf (
360
+ CLICK_VERSION < (8 , 1 ), 'Click < 8.1.0 stores the modified help string'
361
+ )
362
+ def test_no_truncation (self ):
363
+ r"""Validate behavior when a \f character is present.
364
+
365
+ https://click.palletsprojects.com/en/8.1.x/documentation/#truncating-help-texts
366
+ """
367
+
368
+ @click .command ()
369
+ def cli ():
370
+ """First paragraph.
371
+
372
+ This is a very long second
373
+ paragraph and not correctly
374
+ wrapped but it will be rewrapped.
375
+ \f
376
+
377
+ :param click.core.Context ctx: Click context.
378
+ """
379
+ pass
380
+
381
+ ctx = click .Context (cli , info_name = 'cli' )
382
+ output = list (ext ._format_command (ctx , nested = 'short' ))
383
+
384
+ # note that we have an extra newline because we're using
385
+ # docutils.statemachine.string2lines under the hood, which is
386
+ # converting the form feed to a newline
387
+ self .assertEqual (
388
+ textwrap .dedent (
389
+ """
390
+ First paragraph.
391
+
392
+ This is a very long second
393
+ paragraph and not correctly
394
+ wrapped but it will be rewrapped.
395
+
396
+
397
+ :param click.core.Context ctx: Click context.
398
+
399
+ .. program:: cli
400
+ .. code-block:: shell
401
+
402
+ cli [OPTIONS]
403
+ """
404
+ ).lstrip (),
405
+ '\n ' .join (output ),
406
+ )
407
+
408
+ def test_no_line_wrapping (self ):
409
+ r"""Validate behavior when a \b character is present.
410
+
411
+ https://click.palletsprojects.com/en/8.1.x/documentation/#preventing-rewrapping
412
+ """
361
413
362
414
@click .command (
363
415
epilog = """
@@ -372,21 +424,38 @@ def test_no_line_wrapping_epilog(self):
372
424
that will be rewrapped again.
373
425
"""
374
426
)
375
- def foobar ():
376
- """A sample command."""
427
+ def cli ():
428
+ """A command containing pre-wrapped text.
377
429
378
- ctx = click .Context (foobar , info_name = 'foobar' )
430
+ \b
431
+ This is
432
+ a paragraph
433
+ without rewrapping.
434
+
435
+ And this is a paragraph
436
+ that will be rewrapped again.
437
+ """
438
+ pass
439
+
440
+ ctx = click .Context (cli , info_name = 'cli' )
379
441
output = list (ext ._format_command (ctx , nested = 'short' ))
380
442
381
443
self .assertEqual (
382
444
textwrap .dedent (
383
445
"""
384
- A sample command.
446
+ A command containing pre-wrapped text .
385
447
386
- .. program:: foobar
448
+ | This is
449
+ | a paragraph
450
+ | without rewrapping.
451
+
452
+ And this is a paragraph
453
+ that will be rewrapped again.
454
+
455
+ .. program:: cli
387
456
.. code-block:: shell
388
457
389
- foobar [OPTIONS]
458
+ cli [OPTIONS]
390
459
391
460
An epilog containing pre-wrapped text.
392
461
@@ -493,99 +562,6 @@ def cli():
493
562
'\n ' .join (output ),
494
563
)
495
564
496
- @unittest .skipIf (
497
- CLICK_VERSION < (8 , 1 ), 'Click < 8.1.0 stores the modified help string'
498
- )
499
- def test_no_truncation (self ):
500
- r"""Validate behavior when a \b character is present.
501
-
502
- https://click.palletsprojects.com/en/8.1.x/documentation/#truncating-help-texts
503
- """
504
-
505
- @click .group ()
506
- def cli ():
507
- """First paragraph.
508
-
509
- This is a very long second
510
- paragraph and not correctly
511
- wrapped but it will be rewrapped.
512
- \f
513
-
514
- :param click.core.Context ctx: Click context.
515
- """
516
- pass
517
-
518
- ctx = click .Context (cli , info_name = 'cli' )
519
- output = list (ext ._format_command (ctx , nested = 'short' ))
520
-
521
- # note that we have an extra newline because we're using
522
- # docutils.statemachine.string2lines under the hood, which is
523
- # converting the form feed to a newline
524
- self .assertEqual (
525
- textwrap .dedent (
526
- """
527
- First paragraph.
528
-
529
- This is a very long second
530
- paragraph and not correctly
531
- wrapped but it will be rewrapped.
532
-
533
-
534
- :param click.core.Context ctx: Click context.
535
-
536
- .. program:: cli
537
- .. code-block:: shell
538
-
539
- cli [OPTIONS] COMMAND [ARGS]...
540
- """
541
- ).lstrip (),
542
- '\n ' .join (output ),
543
- )
544
-
545
- def test_no_line_wrapping (self ):
546
- r"""Validate behavior when a \b character is present.
547
-
548
- https://click.palletsprojects.com/en/8.1.x/documentation/#preventing-rewrapping
549
- """
550
-
551
- @click .group ()
552
- def cli ():
553
- """A sample command group.
554
-
555
- \b
556
- This is
557
- a paragraph
558
- without rewrapping.
559
-
560
- And this is a paragraph
561
- that will be rewrapped again.
562
- """
563
- pass
564
-
565
- ctx = click .Context (cli , info_name = 'cli' )
566
- output = list (ext ._format_command (ctx , nested = 'short' ))
567
-
568
- self .assertEqual (
569
- textwrap .dedent (
570
- """
571
- A sample command group.
572
-
573
- | This is
574
- | a paragraph
575
- | without rewrapping.
576
-
577
- And this is a paragraph
578
- that will be rewrapped again.
579
-
580
- .. program:: cli
581
- .. code-block:: shell
582
-
583
- cli [OPTIONS] COMMAND [ARGS]...
584
- """
585
- ).lstrip (),
586
- '\n ' .join (output ),
587
- )
588
-
589
565
590
566
class NestedCommandsTestCase (unittest .TestCase ):
591
567
"""Validate ``click.Command`` instances inside ``click.Group`` instances."""
0 commit comments