Mercurial > silorider
annotate tests/mockutil.py @ 59:b404445082f8
Prevent unit tests from downloading fake posts
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 28 Oct 2023 11:54:24 -0700 |
parents | 27543b2e73b9 |
children |
rev | line source |
---|---|
2 | 1 |
2 def mock_urllib(m): | |
3 import urllib.request | |
4 m.setattr(urllib.request, 'urlretrieve', _patched_urlretrieve) | |
5 m.setattr(urllib.request, 'urlcleanup', _patched_urlcleanup) | |
6 return m | |
7 | |
8 | |
59
b404445082f8
Prevent unit tests from downloading fake posts
Ludovic Chabant <ludovic@chabant.com>
parents:
2
diff
changeset
|
9 def _patched_urlretrieve(url, filename=None): |
2 | 10 return ('/retrieved/' + url.lstrip('/'), None) |
11 | |
12 | |
13 def _patched_urlcleanup(): | |
14 pass |