Skip to content

Commit

Permalink
🧪 Integrate Hypothesis in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Apr 26, 2023
1 parent cfc634e commit e6af87c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-e .
hypothesis >= 6.0
idna==3.4
multidict==6.0.4
pytest==7.3.1
Expand Down
30 changes: 30 additions & 0 deletions tests/test_quoting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import pytest
from hypothesis import HealthCheck, given, settings
from hypothesis import strategies as st

from yarl._quoting import NO_EXTENSIONS
from yarl._quoting_py import _Quoter as _PyQuoter
Expand Down Expand Up @@ -448,3 +450,31 @@ def test_quoter_path_with_plus(quoter):
def test_unquoter_path_with_plus(unquoter):
s = "/test/x+y%2Bz/:+%2B/"
assert "/test/x+y+z/:++/" == unquoter(unsafe="+")(s)


@settings(suppress_health_check=(HealthCheck.function_scoped_fixture,))
@given(
text_input=st.text(),
safe=st.text(),
unsafe=st.text(),
protected=st.text(),
qs=st.booleans(),
requote=st.booleans(),
)
def test_quote_unquote_parameter(
quoter: _PyQuoter,
unquoter: _PyUnquoter,
safe: str,
unsafe: str,
protected: str,
qs: bool,
requote: bool,
text_input: str,
) -> None:
quote = quoter(safe=safe, protected=protected, qs=qs, requote=requote)
unquote = unquoter(unsafe=unsafe, qs=qs)

text_quoted = quote(text_input)
text_output = unquote(text_quoted)

assert text_input == text_output

0 comments on commit e6af87c

Please sign in to comment.