-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A long string without spaces would cause infinite recursion because the space at the beginning would always be found. Now the function is tested thoroughly.
- Loading branch information
Showing
2 changed files
with
28 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import re | ||
|
||
from hypothesis import given | ||
from hypothesis.strategies import text | ||
|
||
from reportengine import helputils | ||
|
||
@given(text(min_size=1, max_size=1000)) | ||
def test_sane_wrap(txt): | ||
ind = ' ' | ||
w = 70 | ||
res = helputils.sane_fill(txt, initial_indent=ind, width=w) | ||
assert res.startswith(ind) | ||
assert re.sub(r'\s', '', txt) == re.sub(r'\s', '', res) | ||
for line in res.splitlines(): | ||
assert line.rfind(' ') < w |