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