def test_integration(self): # Test that we can: # - run sdist from the repo in a venv # - install the resulting tarball in a new venv # - pip install the repo # - pip install -e the repo # We don't break these into separate tests because we'd need separate # source dirs to isolate from side effects of running pip, and the # overheads of setup would start to beat the benefits of parallelism. self.useFixture(base.CapturedSubprocess( 'sync-req', ['python', 'update.py', os.path.join(REPODIR, self.short_name)], cwd=os.path.join(REPODIR, 'requirements'))) self.useFixture(base.CapturedSubprocess( 'commit-requirements', 'git diff --quiet || git commit -amrequirements', cwd=os.path.join(REPODIR, self.short_name), shell=True)) path = os.path.join( self.useFixture(fixtures.TempDir()).path, 'project') self.useFixture(base.CapturedSubprocess( 'clone', ['git', 'clone', os.path.join(REPODIR, self.short_name), path])) venv = self.useFixture(Venv('sdist', modules=['pip', 'wheel', PBRVERSION], pip_cmd=PIP_CMD)) python = venv.python self.useFixture(base.CapturedSubprocess( 'sdist', [python, 'setup.py', 'sdist'], cwd=path)) venv = self.useFixture(Venv('tarball', modules=['pip', 'wheel', PBRVERSION], pip_cmd=PIP_CMD)) python = venv.python filename = os.path.join( path, 'dist', os.listdir(os.path.join(path, 'dist'))[0]) self.useFixture(base.CapturedSubprocess( 'tarball', [python] + PIP_CMD + [filename])) venv = self.useFixture(Venv('install-git', modules=['pip', 'wheel', PBRVERSION], pip_cmd=PIP_CMD)) root = venv.path python = venv.python self.useFixture(base.CapturedSubprocess( 'install-git', [python] + PIP_CMD + ['git+file://' + path])) if self.short_name == 'nova': found = False for _, _, filenames in os.walk(root): if 'migrate.cfg' in filenames: found = True self.assertTrue(found) venv = self.useFixture(Venv('install-e', modules=['pip', 'wheel', PBRVERSION], pip_cmd=PIP_CMD)) root = venv.path python = venv.python self.useFixture(base.CapturedSubprocess( 'install-e', [python] + PIP_CMD + ['-e', path]))
def test_pip_versions(self): pkgs = { 'test_markers': {'requirements.txt': textwrap.dedent("""\ pkg_a; python_version=='1.2' pkg_b; python_version!='1.2' """)}, 'pkg_a': {}, 'pkg_b': {}, } pkg_dirs = self.useFixture(CreatePackages(pkgs)).package_dirs temp_dir = self.useFixture(fixtures.TempDir()).path repo_dir = os.path.join(temp_dir, 'repo') venv = self.useFixture(Venv('markers')) bin_python = venv.python os.mkdir(repo_dir) for module in self.modules: self._run_cmd( bin_python, ['-m', 'pip', 'install', '--upgrade', module], cwd=venv.path, allow_fail=False) for pkg in pkg_dirs: self._run_cmd( bin_python, ['setup.py', 'sdist', '-d', repo_dir], cwd=pkg_dirs[pkg], allow_fail=False) self._run_cmd( bin_python, ['-m', 'pip', 'install', '--no-index', '-f', repo_dir, 'test_markers'], cwd=venv.path, allow_fail=False) self.assertIn('pkg-b', self._run_cmd( bin_python, ['-m', 'pip', 'freeze'], cwd=venv.path, allow_fail=False)[0])
def test_lts_venv_default_versions(self): venv = self.useFixture(Venv('setuptools', modules=self.modules)) bin_python = venv.python pbr = 'file://%s#egg=pbr' % PBR_ROOT # Installing PBR is a reasonable indication that we are not broken on # this particular combination of setuptools and pip. self._run_cmd(bin_python, ['-m', 'pip', 'install', pbr], cwd=venv.path, allow_fail=False)
def test_install_without_pbr(self): # Test easy-install of a thing that depends on a thing using pbr tempdir = self.useFixture(fixtures.TempDir()).path # A directory containing sdists of the things we're going to depend on # in using-package. dist_dir = os.path.join(tempdir, 'distdir') os.mkdir(dist_dir) self._run_cmd(sys.executable, ('setup.py', 'sdist', '-d', dist_dir), allow_fail=False, cwd=PBR_ROOT) # testpkg - this requires a pbr-using package test_pkg_dir = os.path.join(tempdir, 'testpkg') os.mkdir(test_pkg_dir) pkgs = { 'pkgTest': { 'setup.py': textwrap.dedent("""\ #!/usr/bin/env python import setuptools setuptools.setup( name = 'pkgTest', tests_require = ['pkgReq'], test_suite='pkgReq' ) """), 'setup.cfg': textwrap.dedent("""\ [easy_install] find_links = %s """ % dist_dir) }, 'pkgReq': { 'requirements.txt': textwrap.dedent("""\ pbr """), 'pkgReq/__init__.py': textwrap.dedent("""\ print("FakeTest loaded and ran") """) }, } pkg_dirs = self.useFixture(CreatePackages(pkgs)).package_dirs test_pkg_dir = pkg_dirs['pkgTest'] req_pkg_dir = pkg_dirs['pkgReq'] self._run_cmd(sys.executable, ('setup.py', 'sdist', '-d', dist_dir), allow_fail=False, cwd=req_pkg_dir) # A venv to test within venv = self.useFixture(Venv('nopbr', ['pip', 'wheel'])) python = venv.python # Run the depending script self.useFixture( base.CapturedSubprocess('nopbr', [python] + ['setup.py', 'test'], cwd=test_pkg_dir))
def test_lts_venv_default_versions(self): if (sys.version_info[0] == 3 and not self.py3support): self.skipTest('This combination will not install with py3, ' 'skipping test') venv = self.useFixture(Venv('setuptools', modules=self.modules)) bin_python = venv.python pbr = 'file://%s#egg=pbr' % PBR_ROOT # Installing PBR is a reasonable indication that we are not broken on # this particular combination of setuptools and pip. self._run_cmd(bin_python, ['-m', 'pip', 'install', pbr], cwd=venv.path, allow_fail=False)
def test_sphinx_runs(self): venv = self.useFixture(Venv('sphinx')) bin_python = venv.python self._run_cmd(bin_python, ['-m', 'pip', 'install', self.module], cwd=venv.path, allow_fail=False) _, err, ret = self._run_cmd(bin_python, ['setup.py', 'build_sphinx'], cwd=self.package_dir, allow_fail=True) if hasattr(self, 'failure'): self.assertNotEqual(0, ret) self.assertIn(self.failure, err) else: self.assertEqual(0, ret)