test_freeze.txt into py

use textwrap.dedent for readability
This commit is contained in:
Jakub Vysoky 2010-02-24 11:24:55 +01:00
parent 56bf88b08e
commit 0ac3f39eb8
3 changed files with 195 additions and 14 deletions

View File

@ -1,5 +1,6 @@
import zipfile
import textwrap
from os.path import abspath, join, dirname, pardir
from test_pip import here, reset_env, run_pip, pyversion, lib_py
from test_pip import write_file
@ -13,10 +14,10 @@ def test_1():
reset_env()
fspkg = 'file://%s/FSPkg' %join(here, 'packages')
dummy = run_pip('install', '-e', fspkg)
pkg_lines = '''-e %s\n''' %fspkg
pkg_lines = pkg_lines + """
-e svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev
pip"""
pkg_lines = textwrap.dedent('''\
-e %s
-e svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev
pip''' % fspkg)
write_file('bundle-req.txt', pkg_lines)
result = run_pip('bundle', '-r', 'bundle-req.txt', 'test.pybundle')
bundle = result.files_after.get('test.pybundle', None)

View File

@ -1,5 +1,6 @@
import tempfile
import textwrap
from test_pip import here, reset_env, run_pip, clear_environ, write_file
import os
@ -50,19 +51,19 @@ def test_4():
environ = clear_environ(os.environ.copy())
environ['PIP_CONFIG_FILE'] = config_file # set this to make pip load it
reset_env(environ)
write_file(config_file, '''\
[global]
index-url = http://download.zope.org/ppix
''')
write_file(config_file, textwrap.dedent('''\
[global]
index-url = http://download.zope.org/ppix
'''))
result = run_pip('install', '-vvv', 'INITools', expect_error=True)
assert "Getting page http://download.zope.org/ppix/INITools" in result.stdout
reset_env(environ)
write_file(config_file, '''\
[global]
index-url = http://download.zope.org/ppix
[install]
index-url = http://pypi.appspot.com/
''')
write_file(config_file, textwrap.dedent('''\
[global]
index-url = http://download.zope.org/ppix
[install]
index-url = http://pypi.appspot.com/
'''))
result = run_pip('install', '-vvv', 'INITools', expect_error=True)
assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
result = run_pip('install', '-vvv', '--index-url', 'http://pypi.python.org/simple', 'INITools', expect_error=True)

179
tests/test_freeze.py Normal file
View File

@ -0,0 +1,179 @@
import os
import textwrap
from doctest import OutputChecker, ELLIPSIS
from test_pip import base_path, reset_env, run_pip, pyversion, lib_py, write_file, get_env
def test_1():
'''
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()
checker = OutputChecker()
write_file('initools-req.txt', textwrap.dedent('''\
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)
expected = textwrap.dedent('''\
Script result: ...ython... pip.main() .../test-scratch freeze
-- stdout: --------------------
INITools==0.2
simplejson==1.7.4...
<BLANKLINE>''')
assert checker.check_output(expected, str(result), ELLIPSIS), result
# 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)
expected = textwrap.dedent('''\
Script result: ...ython... pip.main() -E .../test-scratch freeze
-- stdout: --------------------
-e svn+http://svn.colorstudy.com/INITools/trunk@3472#egg=INITools-0.2.1dev_r3472-py2...-dev_r3472
simplejson==1.7.4...
<BLANKLINE>''')
assert checker.check_output(expected, str(result), ELLIPSIS), result
# 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)
expected = textwrap.dedent('''\
Script result: ...ython... pip.main() -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>''')
assert checker.check_output(expected, str(result), ELLIPSIS), result
# 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)
expected = textwrap.dedent('''\
Script result: ...ython... pip.main() -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>''')
assert checker.check_output(expected, str(result), ELLIPSIS), result
def test_2():
'''
What about a Git clone?::
'''
reset_env()
env = get_env()
checker = OutputChecker()
result = env.run('git', 'clone', 'git://github.com/jezdez/django-pagination.git', 'django-pagination')
result = env.run('git', 'checkout', '1df6507872d73ee387eb375428eafbfc253dfcd8',
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)
expected = textwrap.dedent('''\
Script result: ...ython... pip.main() -E .../test-scratch freeze
-- stdout: --------------------
-e git://github.com/jezdez/django-pagination.git@...#egg=django_pagination-...
...''')
assert checker.check_output(expected, str(result), ELLIPSIS), result
result = run_pip('freeze', '-f', 'git://github.com/jezdez/django-pagination.git#egg=django_pagination', expect_stderr=True)
expected = textwrap.dedent('''\
Script result: ...ython... pip.main() -E .../test-scratch freeze -f git://github.com/jezdez/django-pagination.git#egg=django_pagination
-- stdout: --------------------
-f git://github.com/jezdez/django-pagination.git#egg=django_pagination
-e git://github.com/jezdez/django-pagination.git@...#egg=django_pagination-...-dev
...''')
assert checker.check_output(expected, str(result), ELLIPSIS), result
def test_3():
'''
Now what about Mercurial::
'''
reset_env()
env = get_env()
checker = OutputChecker()
result = env.run('hg', 'clone', '-r', 'f8f7eaf275c5', 'http://bitbucket.org/jezdez/django-dbtemplates/', 'django-dbtemplates')
result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
cwd=os.path.join(env.base_path, 'django-dbtemplates'))
result = run_pip('freeze', expect_stderr=True)
expected = textwrap.dedent('''\
Script result: ...ython... pip.main() -E .../test-scratch freeze
-- stdout: --------------------
-e hg+http://bitbucket.org/jezdez/django-dbtemplates/@...#egg=django_dbtemplates-...
...''')
assert checker.check_output(expected, str(result), ELLIPSIS), result
result = run_pip('freeze', '-f', 'hg+http://bitbucket.org/jezdez/django-dbtemplates#egg=django_dbtemplates', expect_stderr=True)
expected = textwrap.dedent('''\
Script result: ...ython... pip.main() -E .../test-scratch freeze -f hg+http://bitbucket.org/jezdez/django-dbtemplates#egg=django_dbtemplates
-- stdout: --------------------
-f hg+http://bitbucket.org/jezdez/django-dbtemplates#egg=django_dbtemplates
-e hg+http://bitbucket.org/jezdez/django-dbtemplates/@...#egg=django_dbtemplates-...
...''')
assert checker.check_output(expected, str(result), ELLIPSIS), result
def test_4():
'''
Heck, now look in the Bazaar::
'''
reset_env()
env = get_env()
checker = OutputChecker()
result = env.run('bzr', 'checkout', '-r', '174', 'http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/', 'django-wikiapp')
result = env.run(os.path.join(env.base_path, 'bin/python'), 'setup.py', 'develop',
cwd=os.path.join(env.base_path, 'django-wikiapp'))
result = run_pip('freeze', expect_stderr=True)
expected = textwrap.dedent('''\
Script result: ...ython... pip.main() -E .../test-scratch freeze
-- stdout: --------------------
-e bzr+http://bazaar.launchpad.net/...django-wikiapp/django-wikiapp/release-0.1/@...#egg=django_wikiapp-...
...''')
assert checker.check_output(expected, str(result), ELLIPSIS), result
result = run_pip('freeze', '-f', 'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/#egg=django-wikiapp', expect_stderr=True)
expected = textwrap.dedent('''\
Script result: ...ython... pip.main() -E .../test-scratch freeze -f bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/#egg=django-wikiapp
-- stdout: --------------------
-f bzr+http://bazaar.launchpad.net/...django-wikiapp/django-wikiapp/release-0.1/#egg=django-wikiapp
-e bzr+http://bazaar.launchpad.net/...django-wikiapp/django-wikiapp/release-0.1/@...#egg=django_wikiapp-...
...''')
assert checker.check_output(expected, str(result), ELLIPSIS), result
def test_5():
'''
Test that wsgiref (from global site-packages) is reported normally, but not with --local::
'''
reset_env()
checker = OutputChecker()
result = run_pip('install', 'initools==0.2')
result = run_pip('freeze', expect_stderr=True)
expected = textwrap.dedent('''\
Script result: ...ython... pip.main() .../test-scratch freeze
-- stdout: --------------------
INITools==0.2
wsgiref==...
<BLANKLINE>''')
assert checker.check_output(expected, str(result), ELLIPSIS), result
result = run_pip('freeze', '--local', expect_stderr=True)
expected = textwrap.dedent('''\
Script result: ...ython... pip.main() .../test-scratch freeze --local
-- stdout: --------------------
INITools==0.2
<BLANKLINE>''')
assert checker.check_output(expected, str(result), ELLIPSIS), result