Mercurial > hg > carton
annotate tests/doctest.txt @ 11:e6a62ba0c24d
now respect the order sources are installed in
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 08 Jul 2011 15:02:44 -0700 |
parents | d1f090c5f291 |
children | f522620c6a78 |
rev | line source |
---|---|
5 | 1 Test carton |
2 =========== | |
3 | |
4 The obligatory imports: | |
5 | |
6 >>> import carton | |
8
5905459d4ebe
now have a passing if somewhat rudimentary test
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
7 >>> import os |
7 | 8 |
9 Make a temporary directory:: | |
10 | |
5 | 11 >>> import tempfile |
7 | 12 >>> directory = tempfile.mkdtemp() |
5 | 13 |
9 | 14 Invoke carton:: |
5 | 15 |
8
5905459d4ebe
now have a passing if somewhat rudimentary test
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
16 >>> os.chdir(directory) |
5905459d4ebe
now have a passing if somewhat rudimentary test
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
17 >>> packages = [os.path.join(here, i) for i in 'packageB', 'packageA'] |
5905459d4ebe
now have a passing if somewhat rudimentary test
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
18 >>> carton.main(['foo'] + packages) |
5905459d4ebe
now have a passing if somewhat rudimentary test
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
19 >>> os.listdir('.') |
5905459d4ebe
now have a passing if somewhat rudimentary test
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
20 ['foo.py'] |
5 | 21 |
10 | 22 Invoke the foo.py it creates:: |
23 | |
24 >>> import subprocess | |
25 >>> subprocess.call([python, 'foo.py'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
26 0 | |
27 >>> sorted(os.listdir('.')) | |
28 ['foo', 'foo.py'] | |
29 >>> os.path.isdir('foo') | |
30 True | |
31 >>> sorted(os.listdir(os.path.join('foo', 'src'))) | |
32 ['packageA', 'packageB'] | |
33 | |
7 | 34 Clean up:: |
35 | |
36 >>> import shutil | |
37 >>> shutil.rmtree(directory) |