-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log repr of incoming message only in debug mode (#80)
Resolved #74.
- Loading branch information
Showing
4 changed files
with
32 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
import pytest | ||
|
||
from ansq.utils import truncate_text | ||
from ansq.utils import truncate | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"text, limit, expected", | ||
( | ||
pytest.param("0123456789", 11, "0123456789", id="no trunc, greater than limit"), | ||
pytest.param("0123456789", 10, "0123456789", id="no trunc, equal limit"), | ||
pytest.param("0123456789", 9, "012345678...", id="trunc"), | ||
pytest.param("0123456789", 1, "0...", id="minimal trunc"), | ||
pytest.param("", 10, "", id="empty string"), | ||
pytest.param( | ||
b"0123456789", 11, b"0123456789", id="no trunc, greater than limit" | ||
), | ||
pytest.param(b"0123456789", 10, b"0123456789", id="no trunc, equal limit"), | ||
pytest.param(b"0123456789", 9, b"012345678...", id="trunc"), | ||
pytest.param(b"0123456789", 1, b"0...", id="minimal trunc"), | ||
pytest.param(b"", 10, b"", id="empty string"), | ||
), | ||
) | ||
def test_truncate_text(text, limit, expected): | ||
assert truncate_text(text, limit) == expected | ||
def test_truncate(text, limit, expected): | ||
assert truncate(text, limit) == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"text, limit", | ||
( | ||
pytest.param("0123456789", 0, id="zero"), | ||
pytest.param("0123456789", -1, id="negative"), | ||
pytest.param(b"0123456789", 0, id="zero"), | ||
pytest.param(b"0123456789", -1, id="negative"), | ||
), | ||
) | ||
def test_truncate_text_raises_value_error(text, limit): | ||
def test_truncate_raises_value_error(text, limit): | ||
with pytest.raises(ValueError, match=r"^limit must be greater than 0$"): | ||
assert truncate_text(text, limit) | ||
assert truncate(text, limit) |