'monkeypatch the actual urlopen calls done by the internal plugin
function that connects to bpaste service.'

@pytest.fixture
def mocked_urlopen(self, monkeypatch):

    calls = []
    def mocked(url, data):
        calls.append((url, data))
        class DummyFile(object, ):
            def read(self):
                return 'View    <a    href="/raw/3c0c6750bd">raw</a>.'
        return DummyFile()
    if (sys.version_info < (3, 0)):
        import urllib
        monkeypatch.setattr(urllib, 'urlopen', mocked)
    else:
        import urllib.request
        monkeypatch.setattr(urllib.request, 'urlopen', mocked)
    return calls
