Source

pip-windows / tests / test_freeze.txt

Full commit
Basic setup::

    >>> import os
    >>> from __main__ import base_path, reset_env, run_pip, pyversion, lib_py, write_file, get_env

Some tests of freeze, first we have to install some stuff.  Note that
the test is a little crude at the end because Python 2.5+ adds egg
info to the standard library, so stuff like wsgiref will show up in
the freezing.  (Probably that should be accounted for in pip, but
currently it is not).  ::

    >>> reset_env()
    >>> write_file('initools-req.txt', '''\
    ... INITools==0.2
    ... # and something else to test out:
    ... simplejson<=1.7.4
    ... ''')
    >>> result = run_pip('install', '-r', 'initools-req.txt')
    >>> result = run_pip('freeze', expect_stderr=True)
    >>> print result
    Script result: ...ython... ../../pip.py -E .../test-scratch freeze
    -- stdout: --------------------
    INITools==0.2
    simplejson==1.7.4...
    <BLANKLINE>

Now lets try it with an svn checkout::

    >>> env = get_env()
    >>> result = env.run('svn', 'co', '-r3472', 'http://svn.colorstudy.com/INITools/trunk', 'initools-trunk')
    >>> result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
    ...                  cwd=os.path.join(env.base_path, 'initools-trunk'))
    >>> result = run_pip('freeze', expect_stderr=True)
    >>> print result
    Script result: ...ython... ../../pip.py -E .../test-scratch freeze
    -- stdout: --------------------
    -e svn+http://svn.colorstudy.com/INITools/trunk@3472#egg=INITools-0.2.1dev_r3472-py2...-dev
    simplejson==1.7.4...
    <BLANKLINE>

Now, straight from trunk (but not editable/setup.py develop)::

    >>> result = env.run(os.path.join(env.base_path, 'bin/easy_install'), 'http://svn.colorstudy.com/INITools/trunk')
    >>> result = run_pip('freeze', expect_stderr=True)
    >>> print result
    Script result: ...ython... ../../pip.py -E .../test-scratch freeze
    -- stderr: --------------------
    Warning: cannot find svn location for INITools==...dev-r...
    <BLANKLINE>
    -- stdout: --------------------
    ## FIXME: could not find svn URL in dependency_links for this package:
    INITools==...dev-r...
    simplejson==1.7.4...
    <BLANKLINE>

Bah, that's no good!  Let's give it a hint::

    >>> result = run_pip('freeze', '-f', 'http://svn.colorstudy.com/INITools/trunk#egg=INITools-dev', expect_stderr=True)
    >>> print result
    Script result: ...ython... ../../pip.py -E .../test-scratch freeze -f http://svn.colorstudy.com/INITools/trunk#egg=INITools-dev
    -- stdout: --------------------
    -f http://svn.colorstudy.com/INITools/trunk#egg=INITools-dev
    # Installing as editable to satisfy requirement INITools==...dev-r...:
    -e svn+http://svn.colorstudy.com/INITools/trunk@...#egg=INITools-...dev_r...
    simplejson==1.7.4...
    <BLANKLINE>

What about a Git clone?::

    >>> reset_env()
    >>> env = get_env()
    >>> result = env.run('git', 'clone', 'git://git.websushi.org/apps/django-pagination/', 'django-pagination')
    >>> result = env.run('git', 'checkout', 'bdc85c1526d84742362b00a6012b3677a4f69f51',
    ...                  cwd=os.path.join(env.base_path, 'django-pagination'), expect_stderr=True)
    >>> result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
    ...                  cwd=os.path.join(env.base_path, 'django-pagination'))
    >>> result = run_pip('freeze', expect_stderr=True)
    >>> print result
    Script result: ...ython... ../../pip.py -E .../test-scratch freeze
    -- stderr: --------------------
    Git URL does not fit normal structure: git://git.websushi.org/apps/django-pagination/
    <BLANKLINE>
    -- stdout: --------------------
    -e git://git.websushi.org/apps/django-pagination/@...#egg=django_pagination-...
    ...
    <BLANKLINE>

    >>> result = run_pip('freeze', '-f', 'git://git.websushi.org/apps/django-pagination/#egg=django_pagination-dev', expect_stderr=True)
    >>> print result
    Script result: ...ython... ../../pip.py -E .../test-scratch freeze -f git://git.websushi.org/apps/django-pagination/#egg=django_pagination-dev
    -- stderr: --------------------
    Git URL does not fit normal structure: git://git.websushi.org/apps/django-pagination/
    <BLANKLINE>
    -- stdout: --------------------
    -f git://git.websushi.org/apps/django-pagination/#egg=django_pagination-dev
    -e git://git.websushi.org/apps/django-pagination/@...#egg=django_pagination-dev
    ...
    <BLANKLINE>

Now what about Mercurial::

    >>> reset_env()
    >>> env = get_env()
    >>> result = env.run('hg', 'clone', '-r', 'a5748745272a', 'http://bitbucket.org/mitsuhiko/pygments-main/', 'pygments')
    >>> result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
    ...                  cwd=os.path.join(env.base_path, 'pygments'))
    >>> result = run_pip('freeze', expect_stderr=True)
    >>> print result
    Script result: ...ython... ../../pip.py -E .../test-scratch freeze
    -- stdout: --------------------
    -e hg+http://bitbucket.org/mitsuhiko/pygments-main/@...#egg=Pygments-...
    ...
    <BLANKLINE>

    >>> result = run_pip('freeze', '-f', 'hg+http://bitbucket.org/mitsuhiko/pygments-main#egg=Pygments', expect_stderr=True)
    >>> print result
    Script result: ...ython... ../../pip.py -E .../test-scratch freeze -f hg+http://bitbucket.org/mitsuhiko/pygments-main#egg=Pygments
    -- stdout: --------------------
    -f hg+http://bitbucket.org/mitsuhiko/pygments-main#egg=Pygments
    -e hg+http://bitbucket.org/mitsuhiko/pygments-main/@...#egg=Pygments-...
    ...
    <BLANKLINE>

Heck, now look in the Bazaar:

    >>> reset_env()
    >>> env = get_env()
    >>> result = env.run('bzr', 'checkout', '-r', '2', 'http://bazaar.launchpad.net/%7Ejezdez/pip-test/test/', 'pip-test')
    >>> result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
    ...                  cwd=os.path.join(env.base_path, 'pip-test'))
    >>> result = run_pip('freeze', expect_stderr=True)
    >>> print result
    Script result: ...ython... ../../pip.py -E .../test-scratch freeze
    -- stdout: --------------------
    -e bzr+http://bazaar.launchpad.net/%7Ejezdez/pip-test/test/@...#egg=pip_test-...
    ...
    <BLANKLINE>

    >>> result = run_pip('freeze', '-f', 'bzr+http://bazaar.launchpad.net/%7Ejezdez/pip-test/test/#egg=pip_test', expect_stderr=True)
    >>> print result
    Script result: ...ython... ../../pip.py -E .../test-scratch freeze -f bzr+http://bazaar.launchpad.net/%7Ejezdez/pip-test/test/#egg=pip_test
    -- stdout: --------------------
    -f bzr+http://bazaar.launchpad.net/%7Ejezdez/pip-test/test/#egg=pip_test
    -e bzr+http://bazaar.launchpad.net/%7Ejezdez/pip-test/test/@...#egg=pip_test-...
    ...
    <BLANKLINE>