def test_cleanup_after_create_bundle(): """ Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/. """ env = reset_env() # Install an editable to create a src/ dir. run_pip('install', '-e', '%s#egg=django-feedutil' % local_checkout('git+http://github.com/jezdez/django-feedutil.git')) build = env.venv_path/"build" src = env.venv_path/"src" assert not exists(build), "build/ dir still exists: %s" % build assert exists(src), "expected src/ dir doesn't exist: %s" % src # Make the bundle. fspkg = 'file://%s/FSPkg' %join(here, 'packages') pkg_lines = textwrap.dedent('''\ -e %s -e %s#egg=initools-dev pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))) write_file('bundle-req.txt', pkg_lines) run_pip('bundle', '-r', 'bundle-req.txt', 'test.pybundle') build_bundle = env.scratch_path/"build-bundle" src_bundle = env.scratch_path/"src-bundle" assert not exists(build_bundle), "build-bundle/ dir still exists: %s" % build_bundle assert not exists(src_bundle), "src-bundle/ dir still exists: %s" % src_bundle # Make sure previously created src/ from editable still exists assert exists(src), "expected src dir doesn't exist: %s" % src
def test_uninstall_from_reqs_file(): """ Test uninstall from a requirements file. """ env = reset_env() write_file('test-req.txt', textwrap.dedent("""\ -e %s#egg=initools-dev # and something else to test out: PyLogo<0.4 """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))) result = run_pip('install', '-r', 'test-req.txt') write_file('test-req.txt', textwrap.dedent("""\ # -f, -i, and --extra-index-url should all be ignored by uninstall -f http://www.example.com -i http://www.example.com --extra-index-url http://www.example.com -e %s#egg=initools-dev # and something else to test out: PyLogo<0.4 """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))) result2 = run_pip('uninstall', '-r', 'test-req.txt', '-y') assert_all_changes( result, result2, [env.venv/'build', env.venv/'src', env.scratch/'test-req.txt'])
def test_create_bundle(): """ Test making a bundle. We'll grab one package from the filesystem (the FSPkg dummy package), one from vcs (initools) and one from an index (pip itself). """ env = reset_env() fspkg = path_to_url2(Path(here) / "packages" / "FSPkg") dummy = run_pip("install", "-e", fspkg) 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) # Create a bundle in env.scratch_path/ test.pybundle result = run_pip("bundle", "-r", env.scratch_path / "bundle-req.txt", env.scratch_path / "test.pybundle") bundle = result.files_after.get(join("scratch", "test.pybundle"), None) assert bundle is not None files = zipfile.ZipFile(bundle.full).namelist() assert "src/FSPkg/" in files assert "src/initools/" in files assert "build/pip/" in files
def _test_config_file_override_stack(config_file): 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, 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, 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) assert "Getting page http://download.zope.org/ppix/INITools" not in result.stdout assert "Getting page http://pypi.appspot.com/INITools" not in result.stdout assert "Getting page http://pypi.python.org/simple/INITools" in result.stdout
def test_outdated_default(): """ Test default behavor of oudated command """ env = reset_env() total_re = re.compile('LATEST: +([0-9.]+)') write_file( 'initools-req.txt', textwrap.dedent("""\ INITools==0.2 # and something else to test out: simplejson==2.0.0 """)) run_pip('install', '-r', env.scratch_path / 'initools-req.txt') result = run_pip('search', 'simplejson') simplejson_ver = total_re.search(str(result)).group(1) result = run_pip('search', 'INITools') initools_ver = total_re.search(str(result)).group(1) result = run_pip('outdated', expect_stderr=True) expected = textwrap.dedent("""\ Script result: pip outdated -- stdout: -------------------- simplejson==2.0.0 (LATEST: %s) INITools==0.2 (LATEST: %s) <BLANKLINE>""" % (simplejson_ver, initools_ver)) _check_output(result, expected)
def test_create_bundle(): """ Test making a bundle. We'll grab one package from the filesystem (the FSPkg dummy package), one from vcs (initools) and one from an index (pip itself). """ env = reset_env() fspkg = path_to_url2(Path(here) / 'packages' / 'FSPkg') run_pip('install', '-e', fspkg) pkg_lines = textwrap.dedent( '''\ -e %s -e %s#egg=initools-dev pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))) write_file('bundle-req.txt', pkg_lines) # Create a bundle in env.scratch_path/ test.pybundle result = run_pip('bundle', '-r', env.scratch_path / 'bundle-req.txt', env.scratch_path / 'test.pybundle') bundle = result.files_after.get(join('scratch', 'test.pybundle'), None) assert bundle is not None files = zipfile.ZipFile(bundle.full).namelist() assert 'src/FSPkg/' in files assert 'src/initools/' in files assert 'build/pip/' in files
def test_upgrade_from_reqs_file(): """ Upgrade from a requirements file. """ env = reset_env() write_file( 'test-req.txt', textwrap.dedent("""\ PyLogo<0.4 # and something else to test out: INITools==0.3 """)) install_result = run_pip('install', '-r', env.scratch_path / 'test-req.txt') write_file( 'test-req.txt', textwrap.dedent("""\ PyLogo # and something else to test out: INITools """)) run_pip('install', '--upgrade', '-r', env.scratch_path / 'test-req.txt') uninstall_result = run_pip('uninstall', '-r', env.scratch_path / 'test-req.txt', '-y') assert_all_changes( install_result, uninstall_result, [env.venv / 'build', 'cache', env.scratch / 'test-req.txt'])
def test_outdated_default(): """ Test default behavor of oudated command """ env = reset_env() total_re = re.compile('LATEST: +([0-9.]+)') write_file('initools-req.txt', textwrap.dedent("""\ INITools==0.2 # and something else to test out: simplejson==2.0.0 """)) run_pip('install', '-r', env.scratch_path/'initools-req.txt') result = run_pip('search', 'simplejson') simplejson_ver = total_re.search(str(result)).group(1) result = run_pip('search', 'INITools') initools_ver = total_re.search(str(result)).group(1) result = run_pip('outdated', expect_stderr=True) expected = textwrap.dedent("""\ Script result: pip outdated -- stdout: -------------------- simplejson==2.0.0 (LATEST: %s) INITools==0.2 (LATEST: %s) <BLANKLINE>""" % (simplejson_ver, initools_ver)) _check_output(result, expected)
def test_config_file_override_stack(): """ Test config files (global, overriding a global config with a local, overriding all with a command line flag). """ f, config_file = tempfile.mkstemp('-pip.cfg', 'test-') 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, 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, 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) assert "Getting page http://download.zope.org/ppix/INITools" not in result.stdout assert "Getting page http://pypi.appspot.com/INITools" not in result.stdout assert "Getting page http://pypi.python.org/simple/INITools" in result.stdout
def _test_config_file_override_stack(config_file): 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, 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, 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) assert "Getting page http://download.zope.org/ppix/INITools" not in result.stdout assert "Getting page http://pypi.appspot.com/INITools" not in result.stdout assert "Getting page http://pypi.python.org/simple/INITools" in result.stdout
def test_cleanup_after_create_bundle(): """ Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/. """ env = reset_env() # Install an editable to create a src/ dir. run_pip( 'install', '-e', '%s#egg=django-feedutil' % local_checkout('git+http://github.com/jezdez/django-feedutil.git')) build = env.venv_path / "build" src = env.venv_path / "src" assert not exists(build), "build/ dir still exists: %s" % build assert exists(src), "expected src/ dir doesn't exist: %s" % src # Make the bundle. fspkg = 'file://%s/FSPkg' % join(here, 'packages') pkg_lines = textwrap.dedent( '''\ -e %s -e %s#egg=initools-dev pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))) write_file('bundle-req.txt', pkg_lines) run_pip('bundle', '-r', 'bundle-req.txt', 'test.pybundle') build_bundle = env.scratch_path / "build-bundle" src_bundle = env.scratch_path / "src-bundle" assert not exists( build_bundle), "build-bundle/ dir still exists: %s" % build_bundle assert not exists( src_bundle), "src-bundle/ dir still exists: %s" % src_bundle # Make sure previously created src/ from editable still exists assert exists(src), "expected src dir doesn't exist: %s" % src
def test_uninstall_from_reqs_file(): """ Test uninstall from a requirements file. """ env = reset_env() write_file( 'test-req.txt', textwrap.dedent("""\ -e %s#egg=initools-dev # and something else to test out: PyLogo<0.4 """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))) result = run_pip('install', '-r', 'test-req.txt') write_file( 'test-req.txt', textwrap.dedent("""\ # -f, -i, and --extra-index-url should all be ignored by uninstall -f http://www.example.com -i http://www.example.com --extra-index-url http://www.example.com -e %s#egg=initools-dev # and something else to test out: PyLogo<0.4 """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))) result2 = run_pip('uninstall', '-r', 'test-req.txt', '-y') assert_all_changes( result, result2, [env.venv / 'build', env.venv / 'src', env.scratch / 'test-req.txt'])
def test_install_folder_using_slash_in_the_end(): r""" Test installing a folder using pip install foldername/ or foldername\ """ env = reset_env() mkdir('mock') pkg_path = env.scratch_path/'mock' write_file('setup.py', mock100_setup_py, pkg_path) result = run_pip('install', 'mock' + os.path.sep) egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion assert egg_folder in result.files_created, str(result)
def test_install_folder_using_slash_in_the_end(): r""" Test installing a folder using pip install foldername/ or foldername\ """ env = reset_env() mkdir('mock') pkg_path = env.scratch_path / 'mock' write_file('setup.py', mock100_setup_py, pkg_path) result = run_pip('install', 'mock' + os.path.sep) egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion assert egg_folder in result.files_created, str(result)
def test_install_folder_using_relative_path(): """ Test installing a folder using pip install folder1/folder2 """ env = reset_env() mkdir('initools') mkdir(Path('initools') / 'mock') pkg_path = env.scratch_path / 'initools' / 'mock' write_file('setup.py', mock100_setup_py, pkg_path) result = run_pip('install', Path('initools') / 'mock') egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion assert egg_folder in result.files_created, str(result)
def test_install_folder_using_relative_path(): """ Test installing a folder using pip install folder1/folder2 """ env = reset_env() mkdir('initools') mkdir(Path('initools')/'mock') pkg_path = env.scratch_path/'initools'/'mock' write_file('setup.py', mock100_setup_py, pkg_path) result = run_pip('install', Path('initools')/'mock') egg_folder = env.site_packages / 'mock-100.1-py%s.egg-info' % pyversion assert egg_folder in result.files_created, str(result)
def test_single_download_from_requirements_file(): """ It should support download (in the scratch path) from PyPi from a requirements file """ env = reset_env() write_file('test-req.txt', textwrap.dedent(""" INITools==0.1 """)) result = run_pip('install', '-r', env.scratch_path/ 'test-req.txt', '-d', '.', expect_error=True) assert Path('scratch')/ 'INITools-0.1.tar.gz' in result.files_created assert env.site_packages/ 'initools' not in result.files_created
def test_find_command_folder_in_path(): """ If a folder named e.g. 'git' is in PATH, and find_command is looking for the 'git' executable, it should not match the folder, but rather keep looking. """ env = reset_env() mkdir('path_one'); path_one = env.scratch_path/'path_one' mkdir(path_one/'foo') mkdir('path_two'); path_two = env.scratch_path/'path_two' write_file(path_two/'foo', '# nothing') from pip.util import find_command found_path = find_command('foo', map(str, [path_one, path_two])) assert found_path == path_two/'foo'
def test_multiple_requirements_files(): """ Test installing from multiple nested requirements files. """ env = reset_env() write_file('initools-req.txt', textwrap.dedent("""\ -e %s@10#egg=INITools-dev -r simplejson-req.txt""" % local_checkout('http://svn.colorstudy.com/INITools/trunk'))) write_file('simplejson-req.txt', textwrap.dedent("""\ simplejson<=1.7.4 """)) result = run_pip('install', '-r', env.scratch_path / 'initools-req.txt') assert result.files_created[env.site_packages/'simplejson'].dir assert result.files_created[env.site_packages/'simplejson-1.7.4-py%s.egg-info' % pyversion].dir assert env.venv/'src'/'initools' in result.files_created
def test_requirements_file(): """ Test installing from a requirements file. """ env = reset_env() 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', env.scratch_path / 'initools-req.txt') assert env.site_packages/'INITools-0.2-py%s.egg-info' % pyversion in result.files_created assert env.site_packages/'initools' in result.files_created assert result.files_created[env.site_packages/'simplejson'].dir assert result.files_created[env.site_packages/'simplejson-1.7.4-py%s.egg-info' % pyversion].dir
def test_find_command_folder_in_path(): """ If a folder named e.g. 'git' is in PATH, and find_command is looking for the 'git' executable, it should not match the folder, but rather keep looking. """ env = reset_env() mkdir('path_one') path_one = env.scratch_path / 'path_one' mkdir(path_one / 'foo') mkdir('path_two') path_two = env.scratch_path / 'path_two' write_file(path_two / 'foo', '# nothing') from pip.util import find_command found_path = find_command('foo', map(str, [path_one, path_two])) assert found_path == path_two / 'foo'
def test_single_download_from_requirements_file(): """ It should support download (in the scratch path) from PyPi from a requirements file """ env = reset_env() write_file( "test-req.txt", textwrap.dedent( """ INITools==0.1 """ ), ) result = run_pip("install", "-r", env.scratch_path / "test-req.txt", "-d", ".", expect_error=True) assert Path("scratch") / "INITools-0.1.tar.gz" in result.files_created assert env.site_packages / "initools" not in result.files_created
def test_respect_order_in_requirements_file(): env = reset_env() write_file('frameworks-req.txt', textwrap.dedent("""\ coverage ordereddict mock """)) result = run_pip('install', '-r', env.scratch_path / 'frameworks-req.txt') downloaded = [line for line in result.stdout.split('\n') if 'Downloading/unpacking' in line] assert 'coverage' in downloaded[0], 'First download should ' \ 'be "coverage" but was "%s"' % downloaded[0] assert 'ordereddict' in downloaded[1], 'Second download should ' \ 'be "ordereddict" but was "%s"' % downloaded[1] assert 'mock' in downloaded[2], 'Third download should ' \ 'be "mock" but was "%s"' % downloaded[2]
def test_single_download_from_requirements_file(): """ It should support download (in the scratch path) from PyPi from a requirements file """ env = reset_env() write_file('test-req.txt', textwrap.dedent(""" INITools==0.1 """)) result = run_pip('install', '-r', env.scratch_path / 'test-req.txt', '-d', '.', expect_error=True) assert Path('scratch') / 'INITools-0.1.tar.gz' in result.files_created assert env.site_packages / 'initools' not in result.files_created
def test_upgrade_from_reqs_file(): """ Upgrade from a requirements file. """ env = reset_env() write_file('test-req.txt', textwrap.dedent("""\ PyLogo<0.4 # and something else to test out: INITools==0.3 """)) install_result = run_pip('install', '-r', env.scratch_path/ 'test-req.txt') write_file('test-req.txt', textwrap.dedent("""\ PyLogo # and something else to test out: INITools """)) run_pip('install', '--upgrade', '-r', env.scratch_path/ 'test-req.txt') uninstall_result = run_pip('uninstall', '-r', env.scratch_path/ 'test-req.txt', '-y') assert_all_changes(install_result, uninstall_result, [env.venv/'build', 'cache', env.scratch/'test-req.txt'])
def test_requirements_file(): """ Test installing from a requirements file. """ env = reset_env() 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', env.scratch_path / 'initools-req.txt') assert env.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion in result.files_created assert env.site_packages / 'initools' in result.files_created assert result.files_created[env.site_packages / 'simplejson'].dir assert result.files_created[env.site_packages / 'simplejson-1.7.4-py%s.egg-info' % pyversion].dir
def test_respect_order_in_requirements_file(): env = reset_env() write_file( 'frameworks-req.txt', textwrap.dedent("""\ bidict ordereddict mock """)) result = run_pip('install', '-r', env.scratch_path / 'frameworks-req.txt') downloaded = [ line for line in result.stdout.split('\n') if 'Downloading/unpacking' in line ] assert 'bidict' in downloaded[0], 'First download should ' \ 'be "bidict" but was "%s"' % downloaded[0] assert 'ordereddict' in downloaded[1], 'Second download should ' \ 'be "ordereddict" but was "%s"' % downloaded[1] assert 'mock' in downloaded[2], 'Third download should ' \ 'be "mock" but was "%s"' % downloaded[2]
def test_multiple_requirements_files(): """ Test installing from multiple nested requirements files. """ env = reset_env() write_file( 'initools-req.txt', textwrap.dedent( """\ -e %s@10#egg=INITools-dev -r simplejson-req.txt""" % local_checkout('http://svn.colorstudy.com/INITools/trunk'))) write_file('simplejson-req.txt', textwrap.dedent("""\ simplejson<=1.7.4 """)) result = run_pip('install', '-r', env.scratch_path / 'initools-req.txt') assert result.files_created[env.site_packages / 'simplejson'].dir assert result.files_created[env.site_packages / 'simplejson-1.7.4-py%s.egg-info' % pyversion].dir assert env.venv / 'src' / 'initools' in result.files_created
def test_create_bundle(): """ Test making a bundle. We'll grab one package from the filesystem (the FSPkg dummy package), one from vcs (initools) and one from an index (pip itself). """ env = reset_env() fspkg = path_to_url2(Path(here)/'packages'/'FSPkg') run_pip('install', '-e', fspkg) pkg_lines = textwrap.dedent('''\ -e %s -e %s#egg=initools-dev pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))) write_file('bundle-req.txt', pkg_lines) # Create a bundle in env.scratch_path/ test.pybundle result = run_pip('bundle', '-r', env.scratch_path/ 'bundle-req.txt', env.scratch_path/ 'test.pybundle') bundle = result.files_after.get(join('scratch', 'test.pybundle'), None) assert bundle is not None files = zipfile.ZipFile(bundle.full).namelist() assert 'src/FSPkg/' in files assert 'src/initools/' in files assert 'build/pip/' in files
def test_freeze(): """ 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). TODO: refactor this test into multiple tests? (and maybe different test style instead of using doctest output checker) """ env = reset_env() 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", env.scratch_path / "initools-req.txt") result = run_pip("freeze", expect_stderr=True) expected = textwrap.dedent( """\ Script result: pip freeze -- stdout: -------------------- INITools==0.2 simplejson==1.7.4... <BLANKLINE>""" ) _check_output(result, expected) # Now lets try it with an svn checkout:: result = env.run("svn", "co", "-r3472", "http://svn.colorstudy.com/INITools/trunk", "initools-trunk") result = env.run("python", "setup.py", "develop", cwd=env.scratch_path / "initools-trunk") result = run_pip("freeze", expect_stderr=True) expected = textwrap.dedent( """\ Script result: ...pip 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>""" ) _check_output(result, expected) # Now, straight from trunk (but not editable/setup.py develop):: result = env.run("easy_install", "http://svn.colorstudy.com/INITools/trunk") result = run_pip("freeze", expect_stderr=True) expected = textwrap.dedent( """\ Script result: ...pip 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>""" ) _check_output(result, expected) # 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: ...pip 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>""" ) _check_output(result, expected)
def test_freeze(): """ 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). TODO: refactor this test into multiple tests? (and maybe different test style instead of using doctest output checker) """ env = reset_env() 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', env.scratch_path / 'initools-req.txt') result = run_pip('freeze', expect_stderr=True) expected = textwrap.dedent("""\ Script result: pip freeze -- stdout: -------------------- INITools==0.2 simplejson==1.7.4... <BLANKLINE>""") _check_output(result, expected) # Now lets try it with an svn checkout:: result = env.run( 'svn', 'co', '-r10', local_repo('svn+http://svn.colorstudy.com/INITools/trunk'), 'initools-trunk') result = env.run('python', 'setup.py', 'develop', cwd=env.scratch_path / 'initools-trunk') result = run_pip('freeze', expect_stderr=True) expected = textwrap.dedent( """\ Script result: ...pip freeze -- stdout: -------------------- -e %s@10#egg=INITools-0.3.1dev_r10-py2...-dev_r10 simplejson==1.7.4... <BLANKLINE>""" % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')) _check_output(result, expected) # Now, straight from trunk (but not editable/setup.py develop):: result = env.run( 'svn', 'co', local_repo('svn+http://svn.colorstudy.com/INITools/trunk'), 'initools_to_easy_install') result = env.run('easy_install', env.scratch_path / 'initools_to_easy_install') result = run_pip('freeze', expect_stderr=True) expected = textwrap.dedent("""\ Script result: ...pip 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>""") _check_output(result, expected) # Bah, that's no good! Let's give it a hint:: result = run_pip( 'freeze', '-f', '%s#egg=INITools-dev' % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'), expect_stderr=True) expected = textwrap.dedent("""\ Script result: ...pip freeze -f %(repo)s#egg=INITools-dev -- stdout: -------------------- -f %(repo)s#egg=INITools-dev # Installing as editable to satisfy requirement INITools==...dev-r...: -e %(repo)s@...#egg=INITools-...dev_r... simplejson==1.7.4... <BLANKLINE>""" % { 'repo': local_checkout('svn+http://svn.colorstudy.com/INITools/trunk') }) _check_output(result, expected)
def test_freeze(): """ 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). TODO: refactor this test into multiple tests? (and maybe different test style instead of using doctest output checker) """ env = reset_env() 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', env.scratch_path/'initools-req.txt') result = run_pip('freeze', expect_stderr=True) expected = textwrap.dedent("""\ Script result: pip freeze -- stdout: -------------------- INITools==0.2 simplejson==1.7.4... <BLANKLINE>""") _check_output(result, expected) # Now lets try it with an svn checkout:: result = env.run('svn', 'co', '-r10', local_repo('svn+http://svn.colorstudy.com/INITools/trunk'), 'initools-trunk') result = env.run('python', 'setup.py', 'develop', cwd=env.scratch_path/ 'initools-trunk') result = run_pip('freeze', expect_stderr=True) expected = textwrap.dedent("""\ Script result: ...pip freeze -- stdout: -------------------- -e %s@10#egg=INITools-0.3.1dev_r10-py2...-dev_r10 simplejson==1.7.4... <BLANKLINE>""" % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')) _check_output(result, expected) # Now, straight from trunk (but not editable/setup.py develop):: result = env.run('svn', 'co', local_repo('svn+http://svn.colorstudy.com/INITools/trunk'), 'initools_to_easy_install') result = env.run('easy_install', env.scratch_path/'initools_to_easy_install') result = run_pip('freeze', expect_stderr=True) expected = textwrap.dedent("""\ Script result: ...pip 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>""") _check_output(result, expected) # Bah, that's no good! Let's give it a hint:: result = run_pip('freeze', '-f', '%s#egg=INITools-dev' % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'), expect_stderr=True) expected = textwrap.dedent("""\ Script result: ...pip freeze -f %(repo)s#egg=INITools-dev -- stdout: -------------------- -f %(repo)s#egg=INITools-dev # Installing as editable to satisfy requirement INITools==...dev-r...: -e %(repo)s@...#egg=INITools-...dev_r... simplejson==1.7.4... <BLANKLINE>""" % {'repo': local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')}) _check_output(result, expected)