1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
from urllib.request import urlopen
import pytest
import pook
from pook.exceptions import PookNoMatches
@pytest.fixture
def URL(httpbin):
return f"{httpbin.url}/status/404"
@pytest.mark.pook(allow_pending_mocks=True)
def test_param_exists_empty_disallowed(URL):
pook.get(URL).param_exists("x").reply(200)
with pytest.raises(PookNoMatches):
urlopen(f"{URL}?x")
@pytest.mark.pook
def test_param_exists_empty_allowed(URL):
pook.get(URL).param_exists("x", allow_empty=True).reply(200)
res = urlopen(f"{URL}?x")
assert res.status == 200
|