Monkeypatch the actual urlopen calls done by the internal plugin function that connects to bpaste service, but return a url in an unexpected format.
(self, monkeypatch: MonkeyPatch)
| 105 | |
| 106 | @pytest.fixture |
| 107 | def mocked_urlopen_invalid(self, monkeypatch: MonkeyPatch): |
| 108 | """Monkeypatch the actual urlopen calls done by the internal plugin |
| 109 | function that connects to bpaste service, but return a url in an |
| 110 | unexpected format.""" |
| 111 | calls = [] |
| 112 | |
| 113 | def mocked(url, data): |
| 114 | calls.append((url, data)) |
| 115 | |
| 116 | class DummyFile: |
| 117 | def read(self): |
| 118 | # part of html of a normal response |
| 119 | return b'View <a href="/invalid/3c0c6750bd">raw</a>.' |
| 120 | |
| 121 | return DummyFile() |
| 122 | |
| 123 | import urllib.request |
| 124 | |
| 125 | monkeypatch.setattr(urllib.request, "urlopen", mocked) |
| 126 | return calls |
| 127 | |
| 128 | @pytest.fixture |
| 129 | def mocked_urlopen(self, monkeypatch: MonkeyPatch): |