From ff1a79381a8e9c98ef584a748defb617ba00f4ad Mon Sep 17 00:00:00 2001 From: Marcus Smith Date: Thu, 13 Jun 2013 22:43:26 -0700 Subject: [PATCH] test changes due to virtualenv not using distribute --- pip/commands/install.py | 7 --- pip/commands/wheel.py | 4 +- tests/functional/test_install_index.py | 2 +- tests/functional/test_install_user.py | 23 ++-------- tests/functional/test_install_wheel.py | 12 ++--- tests/functional/test_search.py | 6 +-- tests/functional/test_wheel.py | 24 +++------- tests/lib/__init__.py | 61 ++++---------------------- tests/lib/test_lib.py | 30 ------------- 9 files changed, 30 insertions(+), 139 deletions(-) diff --git a/pip/commands/install.py b/pip/commands/install.py index 2c953420e..b4f37fd7e 100644 --- a/pip/commands/install.py +++ b/pip/commands/install.py @@ -232,13 +232,6 @@ class InstallCommand(Command): logger.warn(msg) return - # import setuptools - # if (options.use_user_site and - # requirement_set.has_editables and - # not getattr(setuptools, '_distribute', False)): - - # raise InstallationError('--user --editable not supported with setuptools, use distribute') - try: if not options.no_download: requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) diff --git a/pip/commands/wheel.py b/pip/commands/wheel.py index 6241c28c4..607ad8b80 100644 --- a/pip/commands/wheel.py +++ b/pip/commands/wheel.py @@ -22,7 +22,7 @@ class WheelCommand(Command): Wheel is a built-package format, and offers the advantage of not recompiling your software during every install. For more details, see the wheel docs: http://wheel.readthedocs.org/en/latest. - Requirements: distribute>=0.6.34 (not setuptools), and wheel. + Requirements: distribute>=0.6.34 or setuptools>=0.7.2, and wheel. 'pip wheel' uses the bdist_wheel setuptools extension from the wheel package to build individual wheels. @@ -78,7 +78,7 @@ class WheelCommand(Command): def run(self, options, args): - # requirements: wheel, and distribute + # confirm requirements try: import wheel.bdist_wheel except ImportError: diff --git a/tests/functional/test_install_index.py b/tests/functional/test_install_index.py index 60d282cf4..6d57e954e 100644 --- a/tests/functional/test_install_index.py +++ b/tests/functional/test_install_index.py @@ -27,7 +27,7 @@ def test_find_links_requirements_file_relative_path(): e = reset_env() write_file('test-req.txt', textwrap.dedent(""" --no-index - --find-links=../../../../data/packages/ + --find-links=../../../data/packages/ parent==0.1 """)) result = run_pip( diff --git a/tests/functional/test_install_user.py b/tests/functional/test_install_user.py index 174ec1d0d..f24339f0d 100644 --- a/tests/functional/test_install_user.py +++ b/tests/functional/test_install_user.py @@ -38,26 +38,11 @@ class Tests_UserSite: assert 'INITools'== project_name, "'%s' should be 'INITools'" %project_name - def test_install_subversion_usersite_editable_with_setuptools_fails(self): - """ - Test installing current directory ('.') into usersite using setuptools fails - """ - # We don't try to use setuptools for 3.X. - if sys.version_info >= (3,): - raise SkipTest() - env = reset_env(use_distribute=False, system_site_packages=True) - result = run_pip('install', '--user', '-e', - '%s#egg=initools-dev' % - local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'), - expect_error=True) - assert '--user --editable not supported with setuptools, use distribute' in result.stdout - - def test_install_subversion_usersite_editable_with_distribute(self): """ Test installing current directory ('.') into usersite after installing distribute """ - env = reset_env(use_distribute=True, system_site_packages=True) + env = reset_env(system_site_packages=True) result = run_pip('install', '--user', '-e', '%s#egg=initools-dev' % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')) @@ -68,7 +53,7 @@ class Tests_UserSite: """ Test installing current directory ('.') into usersite """ - env = reset_env(use_distribute=True, system_site_packages=True) + env = reset_env(system_site_packages=True) run_from = abspath(join(tests_data, 'packages', 'FSPkg')) result = run_pip('install', '--user', curdir, cwd=run_from, expect_error=False) fspkg_folder = env.user_site/'fspkg' @@ -225,7 +210,7 @@ class Tests_UserSite: """ Test uninstall editable local user install """ - env = reset_env(use_distribute=True, system_site_packages=True) + env = reset_env(, system_site_packages=True) #install to_install = abspath(join(tests_data, 'packages', 'FSPkg')) @@ -245,7 +230,7 @@ class Tests_UserSite: """ Test user install from wheel """ - env = reset_env(system_site_packages=True, use_distribute=True) + env = reset_env(system_site_packages=True) pip_install_local('wheel') result = run_pip('install', 'simple.dist==0.1', '--user', '--use-wheel', '--no-index', '--find-links='+find_links) diff --git a/tests/functional/test_install_wheel.py b/tests/functional/test_install_wheel.py index 80150f252..46df6c87b 100644 --- a/tests/functional/test_install_wheel.py +++ b/tests/functional/test_install_wheel.py @@ -9,7 +9,7 @@ def test_install_from_wheel(): """ Test installing from a wheel. """ - env = reset_env(use_distribute=True) + env = reset_env() result = run_pip('install', 'simple.dist', '--use-wheel', '--no-index', '--find-links='+find_links, expect_error=False) @@ -27,7 +27,7 @@ def test_install_from_wheel_with_extras(): import ast except ImportError: raise SkipTest("Need ast module to interpret wheel extras") - env = reset_env(use_distribute=True) + env = reset_env() result = run_pip('install', 'complex-dist[simple]', '--use-wheel', '--no-index', '--find-links='+find_links, expect_error=False) @@ -45,7 +45,7 @@ def test_install_from_wheel_file(): """ Test installing directly from a wheel file. """ - env = reset_env(use_distribute=True) + env = reset_env() package = abspath(join(tests_data, 'packages', 'headers.dist-0.1-py2.py3-none-any.whl')) @@ -60,7 +60,7 @@ def test_install_wheel_with_target(): """ Test installing a wheel using pip install --target """ - env = reset_env(use_distribute=True) + env = reset_env() pip_install_local('wheel') target_dir = env.scratch_path/'target' result = run_pip('install', 'simple.dist==0.1', '-t', target_dir, '--use-wheel', @@ -73,7 +73,7 @@ def test_install_from_wheel_installs_deps(): Test can install dependencies of wheels """ # 'requires_source' depends on the 'source' project - env = reset_env(use_distribute=True) + env = reset_env() package = abspath(join(tests_data, 'packages', 'requires_source-1.0-py2.py3-none-any.whl')) @@ -86,7 +86,7 @@ def test_install_from_wheel_no_deps(): Test --no-deps works with wheel installs """ # 'requires_source' depends on the 'source' project - env = reset_env(use_distribute=True) + env = reset_env() package = abspath(join(tests_data, 'packages', 'requires_source-1.0-py2.py3-none-any.whl')) diff --git a/tests/functional/test_search.py b/tests/functional/test_search.py index 7388ebc66..000102740 100644 --- a/tests/functional/test_search.py +++ b/tests/functional/test_search.py @@ -80,7 +80,7 @@ def test_search_missing_argument(): """ Test missing required argument for search """ - env = reset_env(use_distribute=True) + env = reset_env() result = run_pip('search', expect_error=True) assert 'ERROR: Missing required argument (search query).' in result.stdout @@ -111,7 +111,7 @@ def test_search_should_exit_status_code_zero_when_find_packages(): """ Test search exit status code for package found """ - env = reset_env(use_distribute=True) + env = reset_env() result = run_pip('search', 'pip') assert result.returncode == SUCCESS @@ -120,6 +120,6 @@ def test_search_exit_status_code_when_finds_no_package(): """ Test search exit status code for no matches """ - env = reset_env(use_distribute=True) + env = reset_env() result = run_pip('search', 'non-existant-package', expect_error=True) assert result.returncode == NO_MATCHES_FOUND, result.returncode diff --git a/tests/functional/test_wheel.py b/tests/functional/test_wheel.py index 4ce377b8b..60db65edf 100644 --- a/tests/functional/test_wheel.py +++ b/tests/functional/test_wheel.py @@ -14,27 +14,15 @@ def test_pip_wheel_fails_without_wheel(): """ Test 'pip wheel' fails without wheel """ - env = reset_env(use_distribute=True) + env = reset_env() result = run_pip('wheel', '--no-index', '-f', find_links, 'simple==3.0', expect_error=True) assert "'pip wheel' requires bdist_wheel" in result.stdout -def test_pip_wheel_setuptools_fails(): - """ - Test 'pip wheel' fails with setuptools - """ - if sys.version_info >= (3, 0): - # virtualenv installs distribute in py3 - raise SkipTest() - env = reset_env(use_distribute=False) - pip_install_local('wheel') - result = run_pip('wheel', '--no-index', '-f', find_links, 'simple==3.0', expect_error=True) - assert "'pip wheel' requires %s" % wheel.distribute_requirement in result.stdout, result.stdout - def test_pip_wheel_success(): """ Test 'pip wheel' success. """ - env = reset_env(use_distribute=True) + env = reset_env() pip_install_local('wheel') result = run_pip('wheel', '--no-index', '-f', find_links, 'simple==3.0') wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot @@ -47,7 +35,7 @@ def test_pip_wheel_fail(): """ Test 'pip wheel' failure. """ - env = reset_env(use_distribute=True) + env = reset_env() pip_install_local('wheel') result = run_pip('wheel', '--no-index', '-f', find_links, 'wheelbroken==0.1') wheel_file_name = 'wheelbroken-0.1-py%s-none-any.whl' % pyversion_nodot @@ -61,7 +49,7 @@ def test_pip_wheel_ignore_wheels_editables(): """ Test 'pip wheel' ignores editables and *.whl files in requirements """ - env = reset_env(use_distribute=True) + env = reset_env() pip_install_local('wheel') local_wheel = '%s/simple.dist-0.1-py2.py3-none-any.whl' % find_links @@ -89,7 +77,7 @@ def test_no_clean_option_blocks_cleaning_after_wheel(): """ Test --no-clean option blocks cleaning after wheel build """ - env = reset_env(use_distribute=True) + env = reset_env() pip_install_local('wheel') result = run_pip('wheel', '--no-clean', '--no-index', '--find-links=%s' % find_links, 'simple') build = env.venv_path/'build'/'simple' @@ -101,7 +89,7 @@ def test_pip_wheel_source_deps(): Test 'pip wheel --use-wheel' finds and builds source archive dependencies of wheels """ # 'requires_source' is a wheel that depends on the 'source' project - env = reset_env(use_distribute=True) + env = reset_env() pip_install_local('wheel') result = run_pip('wheel', '--use-wheel', '--no-index', '-f', find_links, 'requires_source') wheel_file_name = 'source-1.0-py%s-none-any.whl' % pyversion_nodot diff --git a/tests/lib/__init__.py b/tests/lib/__init__.py index 22133d1d2..8f91512c9 100644 --- a/tests/lib/__init__.py +++ b/tests/lib/__init__.py @@ -55,12 +55,10 @@ def demand_dirs(path): sys.path = [src_folder] + sys.path -def create_virtualenv(where, distribute=False): +def create_virtualenv(where): import virtualenv - if sys.version_info[0] > 2: - distribute = True virtualenv.create_environment( - where, use_distribute=distribute, unzip_setuptools=True) + where, unzip_setuptools=True) return virtualenv.path_locations(where) @@ -90,26 +88,9 @@ def clear_environ(environ): return dict(((k, v) for k, v in environ.items() if not k.lower().startswith('pip_'))) - -def install_setuptools(env): - easy_install = os.path.join(env.bin_path, 'easy_install') - version = 'setuptools==0.6c11' - if sys.platform != 'win32': - return env.run(easy_install, version) - - tempdir = tempfile.mkdtemp() - try: - for f in glob.glob(easy_install+'*'): - shutil.copy2(f, tempdir) - return env.run(os.path.join(tempdir, 'easy_install'), version) - finally: - rmtree(tempdir) - - env = None def reset_env(environ=None, - use_distribute=False, system_site_packages=False, sitecustomize=None, insecure=True): @@ -117,24 +98,15 @@ def reset_env(environ=None, Keyword arguments: environ: an environ object to use. - use_distribute: use distribute, not setuptools. system_site_packages: create a virtualenv that simulates --system-site-packages. sitecustomize: a string containing python code to add to sitecustomize.py. insecure: how to set the --insecure option for py25 tests. """ - if sys.version_info >= (3,): - use_distribute = True - global env - if use_distribute: - test_class = TestPipEnvironmentD - else: - test_class = TestPipEnvironment - - env = test_class(environ, sitecustomize=sitecustomize) - test_class.rebuild_venv = False + env = TestPipEnvironment(environ, sitecustomize=sitecustomize) + TestPipEnvironment.rebuild_venv = False if system_site_packages: #testing often occurs starting from a private virtualenv (e.g. with tox) @@ -142,7 +114,7 @@ def reset_env(environ=None, #to create a 'system-site-packages' virtualenv #hence, this workaround (env.lib_path/'no-global-site-packages.txt').rm() - test_class.rebuild_venv = True + TestPipEnvironment.rebuild_venv = True return env @@ -303,16 +275,13 @@ class TestPipEnvironment(TestFileEnvironment): exe = sys.platform == 'win32' and '.exe' or '' verbose = False - use_distribute = False - # Keep short to undercut windows path length issues - setuptools = 's' rebuild_venv = True def __init__(self, environ=None, sitecustomize=None): import virtualenv - self.root_path = fast_test_env_root / self.setuptools - self.backup_path = fast_test_env_backup / self.setuptools + self.root_path = fast_test_env_root + self.backup_path = fast_test_env_backup self.scratch_path = self.root_path / self.scratch @@ -366,7 +335,7 @@ class TestPipEnvironment(TestFileEnvironment): demand_dirs(self.scratch_path) # Create a virtualenv and remember where it's putting things. - create_virtualenv(self.venv_path, distribute=self.use_distribute) + create_virtualenv(self.venv_path) demand_dirs(self.user_site_path) @@ -382,10 +351,6 @@ class TestPipEnvironment(TestFileEnvironment): "Oops! 'python' in our test environment runs %r" " rather than expected %r" % (pythonbin, self.bin_path/'python')) - # make sure we have current setuptools to avoid svn incompatibilities - if not self.use_distribute: - install_setuptools(self) - # Uninstall whatever version of pip came with the virtualenv. # Earlier versions of pip were incapable of # self-uninstallation on Windows, so we use the one we're testing. @@ -469,16 +434,6 @@ class TestPipEnvironment(TestFileEnvironment): os.remove(cache_path) - -class TestPipEnvironmentD(TestPipEnvironment): - """A specialized TestFileEnvironment that contains distribute""" - - use_distribute = True - # Keep short to undercut windows path length issues - setuptools = 'd' - rebuild_venv = True - - def run_pip(*args, **kw): result = env.run('pip', *args, **kw) ignore = [] diff --git a/tests/lib/test_lib.py b/tests/lib/test_lib.py index 5c5e96f98..505d0af59 100644 --- a/tests/lib/test_lib.py +++ b/tests/lib/test_lib.py @@ -44,17 +44,9 @@ class Test_reset_env: f = open(self.test_file, 'w') f.close() - # create a TestPipEnvironmentD env and add a file to the backup - self.envD = reset_env(use_distribute=True) - self.test_fileD = self.envD.backup_path / self.envD.venv / 'test_fileD' - f = open(self.test_fileD, 'w') - f.close() - def teardown(self): if os.path.isfile(self.test_file): self.test_file.rm() - if os.path.isfile(self.test_fileD): - self.test_fileD.rm() def test_cache_venv(self): """ @@ -62,18 +54,7 @@ class Test_reset_env: """ env = reset_env() assert os.path.isfile(self.test_file) - env = reset_env(use_distribute=True) - assert os.path.isfile(self.test_fileD) - def test_reset_env_seperate(self): - """ - Test TestPipEnvironment and TestPipEnvironmentD classes maintain seperate caches in py2 - """ - # skip for py3 because both classes use the distribute cache - if sys.version_info > (3, 0): - raise SkipTest() - assert not os.path.isfile(self.env.backup_path / self.env.venv / 'test_fileD') - assert not os.path.isfile(self.envD.backup_path / self.envD.venv / 'test_file') def test_reset_env_system_site_packages(self): """ @@ -127,17 +108,6 @@ def test_sitecustomize_not_growing_in_fast_environment(): def test_tmp_dir_exists_in_env(): - """ - Test that $TMPDIR == env.temp_path and path exists, and env.assert_no_temp() passes - """ - #need these tests to ensure the assert_no_temp feature of scripttest is working - env = reset_env(use_distribute=True) - env.assert_no_temp() #this fails if env.tmp_path doesn't exist - assert env.environ['TMPDIR'] == env.temp_path - assert isdir(env.temp_path) - - -def test_tmp_dir_exists_in_fast_env(): """ Test that $TMPDIR == env.temp_path and path exists and env.assert_no_temp() passes (in fast env) """