Mercurial > hg > fetch
comparison tests/doctest.txt @ 22:63ff1b00ec05
first passing test
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 09 Nov 2011 20:11:05 -0800 |
parents | 0706968f01bb |
children | 1c963875e6cd |
comparison
equal
deleted
inserted
replaced
21:0706968f01bb | 22:63ff1b00ec05 |
---|---|
1 Test fetch | 1 Test fetch |
2 ================ | 2 ========== |
3 | 3 |
4 The obligatory imports:: | 4 The obligatory imports:: |
5 | 5 |
6 >>> import fetch | 6 >>> import fetch |
7 >>> import os | |
8 >>> import shutil | |
9 >>> import tempfile | |
10 | |
11 Create a staging directory:: | |
12 | |
13 >>> stage = tempfile.mkdtemp() | |
7 | 14 |
8 Create a Fetch object:: | 15 Create a Fetch object:: |
9 | 16 |
10 >>> f = fetch.Fetch(strict=True) | 17 >>> f = fetch.Fetch(relative_to=stage, strict=True) |
18 | |
19 Call Fetch directly:: | |
11 | 20 |
21 >>> def url(*args): | |
22 ... return 'file://' + os.path.join(*([here] + list(args))) | |
23 >>> f(url=url('sample1.txt'), destination=stage, type='file') | |
24 >>> file(os.path.join(stage, 'sample1.txt')).read().strip() | |
25 'sample1' | |
26 | |
27 Cleanup:: | |
28 | |
29 >>> shutil.rmtree(stage) |