Add test for #5782

This commit is contained in:
Bruno Oliveira 2019-08-24 14:41:06 -03:00
parent a4adf511fc
commit 691c706fcc
1 changed files with 12 additions and 0 deletions

View File

@ -116,3 +116,15 @@ class TestPaste:
assert "lexer=%s" % lexer in data.decode()
assert "code=full-paste-contents" in data.decode()
assert "expiry=1week" in data.decode()
def test_create_new_paste_failure(self, pastebin, monkeypatch):
import io
import urllib.request
def response(url, data):
stream = io.BytesIO(b"something bad occurred")
return stream
monkeypatch.setattr(urllib.request, "urlopen", response)
result = pastebin.create_new_paste(b"full-paste-contents")
assert result == "bad response: something bad occurred"