Commit 62c0d29
committed
Mitigate testing discrepancies from click 8.2.0 and below
A discrepancy exists between the documentation of `click.prompt` and the
actual behavior of `click.prompt` when mocked with
`click.testing.CliRunner` on click 8.2.0 and below
([`pallets/click#2934`][BUG2934]): when prompting for input and if at
end-of-file, the `CliRunner` may return an empty string instead of
raising `click.Abort`. This usually translates to extra line breaks in
the "mixed" and "echoed" runner output at the last prompt(s).
We mitigate this discrepancy from both sides. On the code side, we wrap
each call to `click.prompt` to treat aborts and empty responses the
same, which is appropriate behavior for the types of prompts we issue.
On the test side, we amend our existing tests to use empty-line input
instead of no input, and explicitly test the "no input" scenario
separately, accepting both the 8.2.0-or-lower or the 8.2.1-or-higher
output. Because the behavior depends on the `click` version, which is
beyond our control, we also adjust coverage measurement.
[BUG2934]: pallets/click#29341 parent 7ecfed1 commit 62c0d29
File tree
2 files changed
+113
-22
lines changed- src/derivepassphrase/_internals
- tests
2 files changed
+113
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
657 | 657 | | |
658 | 658 | | |
659 | 659 | | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
668 | 678 | | |
669 | 679 | | |
670 | 680 | | |
| |||
763 | 773 | | |
764 | 774 | | |
765 | 775 | | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
776 | 795 | | |
777 | 796 | | |
778 | 797 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
669 | | - | |
| 669 | + | |
670 | 670 | | |
671 | 671 | | |
672 | 672 | | |
673 | 673 | | |
674 | | - | |
| 674 | + | |
675 | 675 | | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
676 | 682 | | |
677 | 683 | | |
678 | 684 | | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
679 | 691 | | |
680 | 692 | | |
681 | 693 | | |
| |||
4406 | 4418 | | |
4407 | 4419 | | |
4408 | 4420 | | |
4409 | | - | |
| 4421 | + | |
4410 | 4422 | | |
4411 | 4423 | | |
4412 | 4424 | | |
| |||
4427 | 4439 | | |
4428 | 4440 | | |
4429 | 4441 | | |
| 4442 | + | |
| 4443 | + | |
| 4444 | + | |
| 4445 | + | |
| 4446 | + | |
| 4447 | + | |
| 4448 | + | |
| 4449 | + | |
| 4450 | + | |
| 4451 | + | |
| 4452 | + | |
| 4453 | + | |
| 4454 | + | |
| 4455 | + | |
| 4456 | + | |
| 4457 | + | |
| 4458 | + | |
| 4459 | + | |
| 4460 | + | |
| 4461 | + | |
| 4462 | + | |
| 4463 | + | |
| 4464 | + | |
| 4465 | + | |
| 4466 | + | |
| 4467 | + | |
| 4468 | + | |
| 4469 | + | |
| 4470 | + | |
| 4471 | + | |
| 4472 | + | |
| 4473 | + | |
| 4474 | + | |
| 4475 | + | |
| 4476 | + | |
| 4477 | + | |
| 4478 | + | |
4430 | 4479 | | |
4431 | 4480 | | |
4432 | 4481 | | |
| |||
4459 | 4508 | | |
4460 | 4509 | | |
4461 | 4510 | | |
4462 | | - | |
| 4511 | + | |
4463 | 4512 | | |
4464 | 4513 | | |
4465 | 4514 | | |
| |||
4472 | 4521 | | |
4473 | 4522 | | |
4474 | 4523 | | |
| 4524 | + | |
| 4525 | + | |
| 4526 | + | |
| 4527 | + | |
| 4528 | + | |
| 4529 | + | |
| 4530 | + | |
| 4531 | + | |
| 4532 | + | |
| 4533 | + | |
| 4534 | + | |
| 4535 | + | |
| 4536 | + | |
| 4537 | + | |
| 4538 | + | |
| 4539 | + | |
| 4540 | + | |
| 4541 | + | |
| 4542 | + | |
| 4543 | + | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
4475 | 4547 | | |
4476 | 4548 | | |
4477 | 4549 | | |
| |||
0 commit comments