Skip to content

Commit

Permalink
Hide the library implementation (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov authored Jul 26, 2020
1 parent 8f8ff9c commit cc8cf7b
Show file tree
Hide file tree
Showing 12 changed files with 13,543 additions and 1,127 deletions.
1 change: 1 addition & 0 deletions CHANGES/483.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hide the library implementation details, make the exposed public list very clean.
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ max-line-length = 88
# warn_redundant_casts = True
# warn_unused_ignores = True

[mypy-idna]
ignore_missing_imports = true

[mypy-pytest]
ignore_missing_imports = true

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
NO_EXTENSIONS = True


extensions = [Extension("yarl._quoting", ["yarl/_quoting.c"])]
extensions = [Extension("yarl._quoting_c", ["yarl/_quoting_c.c"])]
# extra_compile_args=["-g"],
# extra_link_args=["-g"],

Expand Down
2 changes: 1 addition & 1 deletion tests/test_cached_property.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from yarl import cached_property
from yarl._url import cached_property


def test_reify():
Expand Down
37 changes: 26 additions & 11 deletions tests/test_quoting.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import pytest

from yarl.quoting import _PyQuoter, _PyUnquoter, _Quoter, _Unquoter
from yarl._quoting import NO_EXTENSIONS

from yarl._quoting_py import _Quoter as _PyQuoter, _Unquoter as _PyUnquoter

@pytest.fixture(params=[_PyQuoter, _Quoter], ids=["py_quoter", "c_quoter"])
def quoter(request):
return request.param

if not NO_EXTENSIONS:
from yarl._quoting_c import _Quoter as _CQuoter, _Unquoter as _CUnquoter

@pytest.fixture(params=[_PyUnquoter, _Unquoter], ids=["py_unquoter", "c_unquoter"])
def unquoter(request):
return request.param
@pytest.fixture(params=[_PyQuoter, _CQuoter], ids=["py_quoter", "c_quoter"])
def quoter(request):
return request.param

@pytest.fixture(params=[_PyUnquoter, _CUnquoter], ids=["py_unquoter", "c_unquoter"])
def unquoter(request):
return request.param


else:

@pytest.fixture(params=[_PyQuoter], ids=["py_quoter"])
def quoter(request):
return request.param

@pytest.fixture(params=[_PyUnquoter], ids=["py_unquoter"])
def unquoter(request):
return request.param


def hexescape(char):
Expand Down Expand Up @@ -336,15 +351,15 @@ def test_quote_protected(quoter):
assert s == "/path%2Fto/three"


def test_quote_fastpath_safe():
def test_quote_fastpath_safe(quoter):
s1 = "/path/to"
s2 = _Quoter(safe="/")(s1)
s2 = quoter(safe="/")(s1)
assert s1 is s2


def test_quote_fastpath_pct():
def test_quote_fastpath_pct(quoter):
s1 = "abc%A0"
s2 = _Quoter()(s1)
s2 = quoter()(s1)
assert s1 is s2


Expand Down
Loading

0 comments on commit cc8cf7b

Please sign in to comment.