Skip to content
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

Add hypothesis tests. #136

Merged
merged 7 commits into from
Jan 4, 2024
Prev Previous commit
Next Next commit
Add hypothesis test for replacing multiple whitespaces
PhilipMay committed Jan 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit f5e0814a47cf363184828007048310232ac59f9f
10 changes: 10 additions & 0 deletions tests/test_text.py
Original file line number Diff line number Diff line change
@@ -47,6 +47,16 @@ def test_replace_and_detect_special_whitespaces_hypothesis(text: str):
assert text_whitespace_count == result_whitespace_count


@settings(max_examples=1000)
@given(text())
def test_replace_multiple_whitespaces_hypothesis(text: str):
result = replace_multiple_whitespaces(text)
text_whitespace_count = text.count(" ")
result_whitespace_count = result.count(" ")
assert len(result) <= len(text)
assert text_whitespace_count <= result_whitespace_count


def test_remove_invisible_characters():
text = "Hello\u200bWorld\u00ad!"
result = remove_invisible_characters(text)