Commits

Dave Abrahams  committed 9a8e0c5

Fix testing so it actually tests this source code in an installed
environment, rather than testing the version of pip that has already
been installed. All tests now pass!

  • Participants
  • Parent commits 936701f

Comments (0)

Files changed (3)

 else:
     kw = dict(scripts=['scripts/pip'])
 
+# Allows reset_env in test_pip.py to invoke setup.py from outside the
+# directory where it's located, which is needed to prepare a proper
+# virtual environment from without performing unnatural contortions.
+os.chdir(os.path.dirname(__file__))
+
 setup(name='pip',
       version=version,
       description="pip installs packages.  Python packages.  An easy_install replacement",

File tests/test_basic.py

     
     """
     reset_env()
+
+    # where this source distribution lives
     base = abspath(join(dirname(__file__), pardir))
+
+    # output will contain the directory of the invoked pip
     result = run_pip('--version')
-    assert base in result.stdout, result.stdout
+
+    # compare the directory tree of the invoked pip with that of this source distribution
+    import re,filecmp
+    dir = re.match(r'\s*pip\s\S+\sfrom\s+(.*)\s\([^(]+\)$', result.stdout).group(1)
+    diffs = filecmp.dircmp(join(base,'pip'), join(dir,'pip'))
+
+    # If any non-matching .py files exist, we have a problem: run_pip
+    # is picking up some other version!  N.B. if this project acquires
+    # primary resources other than .py files, this code will need
+    # maintenance
+    mismatch_py = [x for x in diffs.left_only + diffs.right_only + diffs.diff_files if x.endswith('.py')]
+    assert not mismatch_py, 'mismatched source files in %r and %r'% (join(base,'pip'), join(dir,'pip'))
 
 def test_distutils_configuration_setting():
     """

File tests/test_pip.py

     env.run(sys.executable, '-m', 'virtualenv', '--no-site-packages', env.base_path)
     # make sure we have current setuptools to avoid svn incompatibilities
     env.run('%s/bin/easy_install' % env.base_path, 'setuptools==0.6c11')
-    # Uninstall (kind of) pip, so PYTHONPATH can take effect:
-    env.run('%s/bin/easy_install' % env.base_path, '-m', 'pip')
+
+    # Uninstall whatever version of pip might have been there
+    env.run('%s/bin/pip' % env.base_path, 'uninstall', '-y', 'pip')
+
+    # Install this version on top of it
+    env.run('python', os.path.join(here,os.pardir,'setup.py'), 'install')
+
     env.run('mkdir', 'src')
 
 def run_pip(*args, **kw):