aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual_test.py
blob: 1d2edc2a0e373f370b0c1418c41d421c2c39148c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/python
import os
import shutil
import tempfile
import urllib2
import subprocess
import sys

def tempdir(func):
    def _tempdir(*args, **kwargs):
        test_dir = tempfile.mkdtemp()
        old_dir = os.getcwd()
        os.chdir(test_dir)
        try:
            return func(*args, **kwargs)
        finally:
            os.chdir(old_dir)
            shutil.rmtree(test_dir)
    return _tempdir

SIMPLE_BUILDOUT = """\
[buildout]

parts = eggs

[eggs]
recipe = zc.recipe.egg

eggs =
    extensions
"""

BOOTSTRAP = 'http://python-distribute.org/bootstrap.py'
PYVER = sys.version.split()[0][:3]

@tempdir
def test_virtualenv():
    """virtualenv with distribute"""
    os.system('virtualenv --no-site-packages . --distribute')
    os.system('bin/easy_install -q distribute==dev')
    # linux specific
    site_pkg = os.listdir(os.path.join('.', 'lib', 'python'+PYVER, 'site-packages'))
    site_pkg.sort()
    assert 'distribute' in site_pkg[0]
    easy_install = os.path.join('.', 'lib', 'python'+PYVER, 'site-packages',
                                'easy-install.pth')
    with open(easy_install) as f:
        res = f.read()
    assert 'distribute' in res
    assert 'setuptools' not in res

@tempdir
def test_full():
    """virtualenv + pip + buildout"""
    os.system('virtualenv --no-site-packages .')
    os.system('bin/easy_install -q distribute==dev')
    os.system('bin/easy_install -qU distribute==dev')
    os.system('bin/easy_install -q pip')
    os.system('bin/pip install -q zc.buildout')
    with open('buildout.cfg', 'w') as f:
        f.write(SIMPLE_BUILDOUT)

    with open('bootstrap.py', 'w') as f:
        f.write(urllib2.urlopen(BOOTSTRAP).read())

    os.system('bin/python bootstrap.py --distribute')
    os.system('bin/buildout -q')
    eggs = os.listdir('eggs')
    eggs.sort()
    assert len(eggs) == 3
    assert eggs[0].startswith('distribute')
    assert eggs[1:] == ['extensions-0.3-py2.6.egg',
                    'zc.recipe.egg-1.2.2-py2.6.egg']


if __name__ == '__main__':
    test_virtualenv()
    test_full()