1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00
pip/tests/lib/test_lib.py

63 lines
1.9 KiB
Python
Raw Normal View History

"""Test the test support."""
from __future__ import absolute_import
2013-05-28 23:58:08 +02:00
import filecmp
import re
from os.path import join, isdir
from tests.lib import SRC_DIR
2012-07-29 05:34:06 +02:00
def test_tmp_dir_exists_in_env(script):
2012-07-29 05:34:06 +02:00
"""
Test that $TMPDIR == env.temp_path and path exists and env.assert_no_temp()
passes (in fast env)
2012-07-29 05:34:06 +02:00
"""
# need these tests to ensure the assert_no_temp feature of scripttest is
# working
script.assert_no_temp() # this fails if env.tmp_path doesn't exist
assert script.environ['TMPDIR'] == script.temp_path
assert isdir(script.temp_path)
2013-05-28 23:58:08 +02:00
def test_correct_pip_version(script):
2013-05-28 23:58:08 +02:00
"""
Check we are running proper version of pip in run_pip.
"""
# output is like:
# pip PIPVERSION from PIPDIRECTORY (python PYVERSION)
result = script.pip('--version')
2013-05-28 23:58:08 +02:00
# compare the directory tree of the invoked pip with that of this source
# distribution
dir = re.match(
2017-03-20 16:37:15 +01:00
r'pip \d+(\.[\d]+)+(\.?(rc|dev|pre|post)\d+)? from (.*) '
r'\(python \d(.[\d])+\)$',
result.stdout
).group(4)
pip_folder = join(SRC_DIR, 'pip')
2013-05-28 23:58:08 +02:00
pip_folder_outputed = join(dir, 'pip')
diffs = filecmp.dircmp(pip_folder, pip_folder_outputed)
# 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: %r' %
(pip_folder, pip_folder_outputed, mismatch_py)
)
def test_as_import(script):
""" test that pip.__init__.py does not shadow
the command submodule with a dictionary
"""
import pip.commands.install as inst
assert inst is not None