view tests/mockutil.py @ 39:c5f73ebb43a5

Replace python-twitter with tweepy to use Twitter's V2 API
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 21 May 2023 09:42:11 -0700
parents 27543b2e73b9
children b404445082f8
line wrap: on
line source


def mock_urllib(m):
    import urllib.request
    m.setattr(urllib.request, 'urlretrieve', _patched_urlretrieve)
    m.setattr(urllib.request, 'urlcleanup', _patched_urlcleanup)
    return m


def _patched_urlretrieve(url):
    return ('/retrieved/' + url.lstrip('/'), None)


def _patched_urlcleanup():
    pass