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

Method test_pastebin_url_error

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

Source from the content-addressed store, hash-verified

177 assert len(mock_urlopen.mock_calls) == 1
178
179 def test_pastebin_url_error(self, pastebin) -> None:
180 import urllib.error
181
182 with mock.patch(
183 "urllib.request.urlopen",
184 side_effect=urllib.error.URLError("the url was bad"),
185 ) as mock_urlopen:
186 result = pastebin.create_new_paste(b"full-paste-contents")
187 assert result == "bad response: <urlopen error the url was bad>"
188 assert len(mock_urlopen.mock_calls) == 1
189
190 def test_create_new_paste(self, pastebin, mocked_urlopen) -> None:
191 result = pastebin.create_new_paste(b"full-paste-contents")

Callers

nothing calls this directly

Calls 1

patchMethod · 0.80

Tested by

no test coverage detected