Skip to content

Test textwrap_body, current_date and sortable_datetime #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Test textwrap_body, current_date and sortable_datetime
  • Loading branch information
hugovk committed Jan 7, 2025
commit 156988c6d9366ef750e3416f23a3512b25497c49
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ optional-dependencies.tests = [
"pyfakefs",
"pytest",
"pytest-cov",
"time-machine",
]
urls.Changelog = "https://github.com/python/blurb/blob/main/CHANGELOG.md"
urls.Homepage = "https://github.com/python/blurb"
Expand Down
61 changes: 61 additions & 0 deletions tests/test_blurb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import time_machine

from blurb import blurb

Expand Down Expand Up @@ -44,6 +45,66 @@ def test_unsanitize_section_changed(section, expected):
assert unsanitized == expected


@pytest.mark.parametrize(
"body, subsequent_indent, expected",
(
(
"This is a test of the textwrap_body function with a string. It should wrap the text to 79 characters.",
"",
(
"This is a test of the textwrap_body function with a string. It should wrap\n"
"the text to 79 characters.\n"
),
),
(
[
"This is a test of the textwrap_body function",
"with an iterable of strings.",
"It should wrap the text to 79 characters.",
],
"",
(
"This is a test of the textwrap_body function with an iterable of strings. It\n"
"should wrap the text to 79 characters.\n"
),
),
(
"This is a test of the textwrap_body function with a string and subsequent indent.",
" ",
(
"This is a test of the textwrap_body function with a string and subsequent\n"
" indent.\n"
),
),
(
"This is a test of the textwrap_body function with a bullet list and subsequent indent. The list should not be wrapped.\n"
"\n"
"* Item 1\n"
"* Item 2\n",
" ",
(
"This is a test of the textwrap_body function with a bullet list and\n"
" subsequent indent. The list should not be wrapped.\n"
"\n"
" * Item 1\n"
" * Item 2\n"
),
),
),
)
def test_textwrap_body(body, subsequent_indent, expected):
assert blurb.textwrap_body(body, subsequent_indent=subsequent_indent) == expected


@time_machine.travel("2025-01-07")
def test_current_date():
assert blurb.current_date() == "2025-01-07"


@time_machine.travel("2025-01-07 16:28:41")
def test_sortable_datetime():
assert blurb.sortable_datetime() == "2025-01-07-16-28-41"

@pytest.mark.parametrize(
"version1, version2",
(
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy