| 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") |