|
1 | 1 | import pytest
|
| 2 | +import time_machine |
2 | 3 |
|
3 | 4 | from blurb import blurb
|
4 | 5 |
|
@@ -44,6 +45,59 @@ def test_unsanitize_section_changed(section, expected):
|
44 | 45 | assert unsanitized == expected
|
45 | 46 |
|
46 | 47 |
|
| 48 | +@pytest.mark.parametrize( |
| 49 | + "body, subsequent_indent, expected", |
| 50 | + ( |
| 51 | + ( |
| 52 | + "This is a test of the textwrap_body function with a string. It should wrap the text to 79 characters.", |
| 53 | + "", |
| 54 | + "This is a test of the textwrap_body function with a string. It should wrap\n" |
| 55 | + "the text to 79 characters.\n", |
| 56 | + ), |
| 57 | + ( |
| 58 | + [ |
| 59 | + "This is a test of the textwrap_body function", |
| 60 | + "with an iterable of strings.", |
| 61 | + "It should wrap the text to 79 characters.", |
| 62 | + ], |
| 63 | + "", |
| 64 | + "This is a test of the textwrap_body function with an iterable of strings. It\n" |
| 65 | + "should wrap the text to 79 characters.\n", |
| 66 | + ), |
| 67 | + ( |
| 68 | + "This is a test of the textwrap_body function with a string and subsequent indent.", |
| 69 | + " ", |
| 70 | + "This is a test of the textwrap_body function with a string and subsequent\n" |
| 71 | + " indent.\n", |
| 72 | + ), |
| 73 | + ( |
| 74 | + "This is a test of the textwrap_body function with a bullet list and subsequent indent. The list should not be wrapped.\n" |
| 75 | + "\n" |
| 76 | + "* Item 1\n" |
| 77 | + "* Item 2\n", |
| 78 | + " ", |
| 79 | + "This is a test of the textwrap_body function with a bullet list and\n" |
| 80 | + " subsequent indent. The list should not be wrapped.\n" |
| 81 | + "\n" |
| 82 | + " * Item 1\n" |
| 83 | + " * Item 2\n", |
| 84 | + ), |
| 85 | + ), |
| 86 | +) |
| 87 | +def test_textwrap_body(body, subsequent_indent, expected): |
| 88 | + assert blurb.textwrap_body(body, subsequent_indent=subsequent_indent) == expected |
| 89 | + |
| 90 | + |
| 91 | +@time_machine.travel("2025-01-07") |
| 92 | +def test_current_date(): |
| 93 | + assert blurb.current_date() == "2025-01-07" |
| 94 | + |
| 95 | + |
| 96 | +@time_machine.travel("2025-01-07 16:28:41") |
| 97 | +def test_sortable_datetime(): |
| 98 | + assert blurb.sortable_datetime() == "2025-01-07-16-28-41" |
| 99 | + |
| 100 | + |
47 | 101 | @pytest.mark.parametrize(
|
48 | 102 | "version1, version2",
|
49 | 103 | (
|
|
0 commit comments