def mocked_urlopen_invalid(self, monkeypatch: MonkeyPatch):
        """Monkeypatch the actual urlopen calls done by the internal plugin
        function that connects to bpaste service, but return a url in an
        unexpected format."""
        calls = []

        def mocked(url, data):
            calls.append((url, data))

            class DummyFile:
                def read(self):
                    # part of html of a normal response
                    return b'View <a href="/invalid/3c0c6750bd">raw</a>.'

            return DummyFile()

        import urllib.request

        monkeypatch.setattr(urllib.request, "urlopen", mocked)
        return calls
Monkeypatch the actual urlopen calls done by the internal plugin
        function that connects to bpaste service, but return a url in an
        unexpected format.
testing/test_pastebin.py