Mercurial > hg > carton
annotate tests/doctest.txt @ 26:e6ee0410ceef
fix bug where os.path.sep is wrongly interpreted
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 10 Jul 2011 18:37:42 -0700 |
parents | e2db2913123d |
children | dace84448c25 |
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) |
13
f522620c6a78
now works properly with tarballs
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
17 >>> packages = [os.path.join(here, i) for i in 'packageC.tar.gz', 'packageB', 'packageA'] |
8
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'))) | |
13
f522620c6a78
now works properly with tarballs
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
32 ['packageA', 'packageB', 'packageC'] |
10 | 33 |
19
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
34 Find a console script. This shows installation went well:: |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
35 |
24 | 36 >>> bin = [os.path.join('foo', i) for i in ('bin', 'Scripts') if os.path.exists(os.path.join('foo', i))][0] |
37 >>> os.path.isdir(bin) | |
38 True | |
19
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
39 >>> os.path.exists(os.path.join(bin, 'packageA')) or os.path.exists(os.path.join(bin, 'packageA.exe')) |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
40 True |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
41 |
25
e2db2913123d
test to ensure we are bringing along virtualenv
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
42 Ensure you're bringing along virtualenv:: |
e2db2913123d
test to ensure we are bringing along virtualenv
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
43 |
e2db2913123d
test to ensure we are bringing along virtualenv
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
44 >>> os.path.exists(os.path.join(bin, 'virtualenv')) or os.path.exists(os.path.join(bin, 'virtualenv.exe')) |
e2db2913123d
test to ensure we are bringing along virtualenv
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
45 True |
e2db2913123d
test to ensure we are bringing along virtualenv
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
46 |
19
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
47 Show that non-package files get carried along too:: |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
48 |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
49 >>> os.path.exists(os.path.join('foo', 'src', 'packageA', 'foo.txt')) |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
50 True |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
51 |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
52 Invoke carton again. This time, package the source so that |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
53 stragglers don't come along:: |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
54 |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
55 >>> carton.main(['bar', '--package'] + packages) |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
56 >>> 'bar.py' in os.listdir('.') |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
57 True |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
58 >>> subprocess.call([python, 'bar.py', '--env', 'fleem'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
59 0 |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
60 >>> os.path.exists('fleem') and os.path.isdir('fleem') |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
61 True |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
62 >>> srcdir = os.path.join('fleem', 'src') |
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
63 >>> packageA = os.path.join(srcdir, [i for i in os.listdir(srcdir) if i.startswith('packageA')][0]) |
24 | 64 >>> os.path.exists(os.path.join(packageA, 'foo.txt')) |
20
e2c9a9a4d524
...except i fuxored my logic
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
65 False |
19
996d579f0dc3
test for --package and --env
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
66 |
7 | 67 Clean up:: |
68 | |
69 >>> import shutil | |
70 >>> shutil.rmtree(directory) |