Skip to content

Commit 691c706

Browse files
committed
Add test for #5782
1 parent a4adf51 commit 691c706

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

testing/test_pastebin.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,15 @@ def test_create_new_paste(self, pastebin, mocked_urlopen):
116116
assert "lexer=%s" % lexer in data.decode()
117117
assert "code=full-paste-contents" in data.decode()
118118
assert "expiry=1week" in data.decode()
119+
120+
def test_create_new_paste_failure(self, pastebin, monkeypatch):
121+
import io
122+
import urllib.request
123+
124+
def response(url, data):
125+
stream = io.BytesIO(b"something bad occurred")
126+
return stream
127+
128+
monkeypatch.setattr(urllib.request, "urlopen", response)
129+
result = pastebin.create_new_paste(b"full-paste-contents")
130+
assert result == "bad response: something bad occurred"

0 commit comments

Comments
 (0)