From 691c706fcc27e4765bdb49b3e3bdf9a95e2bf283 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 24 Aug 2019 14:41:06 -0300 Subject: [PATCH] Add test for #5782 --- testing/test_pastebin.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/testing/test_pastebin.py b/testing/test_pastebin.py index 9afa1e23f..4e8bac56c 100644 --- a/testing/test_pastebin.py +++ b/testing/test_pastebin.py @@ -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"