Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get():
res = req.get("https://httpbin.org/get")
assert res.ok
assert res.status_code == 200
json = res.json()
assert all(k in json for k in ("url", "origin", "headers", "args"))
res.raise_for_status()
res = req.get("http://httpbin.org/status/404")
assert not res.ok
assert res.status_code == 404
with pytest.raises(HTTPError):
res.raise_for_status()
assert str(res) == "".format(
code = 404
)
def test_get():
res = req.get("https://httpbin.org/get")
assert res.ok
assert res.status_code == 200
json = res.json()
assert all(k in json for k in ("url", "origin", "headers", "args"))
res.raise_for_status()
res = req.get("http://httpbin.org/status/404")
assert not res.ok
assert res.status_code == 404
with pytest.raises(HTTPError):
res.raise_for_status()
assert str(res) == "".format(
def _get_pypi_package_info(package, raise_err = False):
url = "https://pypi.org/pypi/{}/json".format(package)
response = req.get(url)
info = None
if response.ok:
json = response.json()
info = json["info"]
else:
if raise_err:
response.raise_for_status()
return info
def _get_pypi_info(name, raise_err = True):
url = "https://pypi.org/pypi/{}/json".format(name)
res = req.get(url)
info = None
if res.ok:
data = res.json()
info = data["info"]
else:
if raise_err:
res.raise_for_status()
return info