MCPcopy
hub / github.com/pytest-dev/pytest / test_pastebin_http_error

Method test_pastebin_http_error

testing/test_pastebin.py:162–177  ·  view source on GitHub ↗
(self, pastebin)

Source from the content-addressed store, hash-verified

160 assert len(mocked_urlopen_invalid) == 1
161
162 def test_pastebin_http_error(self, pastebin) -> None:
163 import urllib.error
164
165 with mock.patch(
166 "urllib.request.urlopen",
167 side_effect=urllib.error.HTTPError(
168 url="https://bpa.st",
169 code=400,
170 msg="Bad request",
171 hdrs=email.message.Message(),
172 fp=io.BytesIO(),
173 ),
174 ) as mock_urlopen:
175 result = pastebin.create_new_paste(b"full-paste-contents")
176 assert result == "bad response: HTTP Error 400: Bad request"
177 assert len(mock_urlopen.mock_calls) == 1
178
179 def test_pastebin_url_error(self, pastebin) -> None:
180 import urllib.error

Callers

nothing calls this directly

Calls 1

patchMethod · 0.80

Tested by

no test coverage detected