def _install_venv(self): path_to_venv = self.path(".venv") if not os.path.isdir(path_to_venv): print("No virtual environment found...Install the virtualenv.") LOG.debug("Virtual environment directory: %s" % path_to_venv) required_vers = (2, 7) if sys.version_info[:2] != required_vers: # NOTE(andreykurilin): let's try to find a suitable python # interpreter for Tempest python_interpreter = costilius.get_interpreter(required_vers) if not python_interpreter: raise exceptions.IncompatiblePythonVersion( version=sys.version, required_version=required_vers) LOG.info( _("Tempest requires Python %(required)s, '%(found)s' was " "found in your system and it will be used for installing" " virtual environment.") % {"required": required_vers, "found": python_interpreter}) else: python_interpreter = sys.executable try: check_output("%s ./tools/install_venv.py" % python_interpreter, shell=True, cwd=self.path()) check_output("%s python setup.py install" % self.venv_wrapper, shell=True, cwd=self.path()) except subprocess.CalledProcessError: if os.path.exists(self.path(".venv")): shutil.rmtree(self.path(".venv")) raise TempestSetupFailure(_("failed to install virtualenv"))
def test_found_correct_python_interpreter_with_distutils( self, mock_environ, mock_isfile, mock_sp_check_output, mock_spawn): vers = (2, 7) interpreter = "something" mock_spawn.find_executable.return_value = interpreter self.assertEqual(interpreter, costilius.get_interpreter(vers)) self.assertFalse(mock_environ.called) self.assertFalse(mock_isfile.called) self.assertFalse(mock_sp_check_output.called)
def test_found_correct_python_interpreter_with_distutils( self, mock_env, mock_isfile, mock_check_output, mock_spawn): vers = (2, 7) interpreter = "something" mock_spawn.find_executable.return_value = interpreter self.assertEqual(interpreter, costilius.get_interpreter(vers)) self.assertFalse(mock_env.called) self.assertFalse(mock_isfile.called) self.assertFalse(mock_check_output.called)
def test_found_correct_python_interpreter_without_distutils( self, mock_environ, mock_isfile, mock_sp_check_output, mock_spawn): vers = (2, 7) paths = ["one_path", "second_path"] mock_environ.get.return_value = ":".join(paths) mock_sp_check_output.return_value = "%s\n" % str(vers) mock_spawn.find_executable.return_value = None found_interpreter = costilius.get_interpreter(vers) self.assertEqual(1, mock_sp_check_output.call_count) self.assertIn(found_interpreter, ["%s/%s" % (f, "python2.7") for f in paths])
def test_found_correct_python_interpreter_without_distutils( self, mock_environ, mock_isfile, mock_sp_check_output, mock_spawn ): vers = (2, 7) paths = ["one_path", "second_path"] mock_environ.get.return_value = ":".join(paths) mock_sp_check_output.return_value = "%s\n" % str(vers) mock_spawn.find_executable.return_value = None found_interpreter = costilius.get_interpreter(vers) self.assertEqual(1, mock_sp_check_output.call_count) self.assertIn(found_interpreter, ["%s/%s" % (f, "python2.7") for f in paths])
def _install_venv(self): path_to_venv = self.path(".venv") if not os.path.isdir(path_to_venv): LOG.debug("No virtual environment for Tempest found.") LOG.info(_("Installing the virtual environment for Tempest.")) LOG.debug("Virtual environment directory: %s" % path_to_venv) required_vers = (2, 7) if sys.version_info[:2] != required_vers: # NOTE(andreykurilin): let's try to find a suitable python # interpreter for Tempest python_interpreter = costilius.get_interpreter(required_vers) if not python_interpreter: raise exceptions.IncompatiblePythonVersion( version=sys.version, required_version=required_vers) LOG.info( _("Tempest requires Python %(required)s, '%(found)s' was " "found in your system and it will be used for installing" " virtual environment.") % { "required": required_vers, "found": python_interpreter }) else: python_interpreter = sys.executable try: check_output("%s ./tools/install_venv.py" % python_interpreter, shell=True, cwd=self.path()) # NOTE(kun): Using develop mode installation is for run # multiple tempest instance. However, dependency # from tempest(os-testr) has issues here, before # https://review.openstack.org/#/c/207691/ being # merged, we have to install dependency manually and # run setup.py with -N(install package without # dependency) check_output("%s pip install -r requirements.txt " "-r test-requirements.txt" % self.venv_wrapper, shell=True, cwd=self.path()) check_output("%s python setup.py develop -N" % self.venv_wrapper, shell=True, cwd=self.path()) except subprocess.CalledProcessError: if os.path.exists(self.path(".venv")): shutil.rmtree(self.path(".venv")) raise TempestSetupFailure(_("failed to install virtualenv"))
def _install_venv(self): path_to_venv = self.path(".venv") if not os.path.isdir(path_to_venv): LOG.debug("No virtual environment for Tempest found.") LOG.info(_("Installing the virtual environment for Tempest.")) LOG.debug("Virtual environment directory: %s" % path_to_venv) required_vers = (2, 7) if sys.version_info[:2] != required_vers: # NOTE(andreykurilin): let's try to find a suitable python # interpreter for Tempest python_interpreter = costilius.get_interpreter(required_vers) if not python_interpreter: raise exceptions.IncompatiblePythonVersion(version=sys.version, required_version=required_vers) LOG.info( _( "Tempest requires Python %(required)s, '%(found)s' was " "found in your system and it will be used for installing" " virtual environment." ) % {"required": required_vers, "found": python_interpreter} ) else: python_interpreter = sys.executable try: check_output(["virtualenv", "-p", python_interpreter, ".venv"], cwd=self.path()) # NOTE(kun): Using develop mode installation is for run # multiple tempest instance. However, dependency # from tempest(os-testr) has issues here, before # https://review.openstack.org/#/c/207691/ being # merged, we have to install dependency manually and # run setup.py with -N(install package without # dependency) check_output( [self.venv_wrapper, "pip", "install", "-r", "requirements.txt", "-r", "test-requirements.txt"], cwd=self.path(), ) check_output([self.venv_wrapper, "pip", "install", "-e", "./"], cwd=self.path()) except subprocess.CalledProcessError: if os.path.exists(self.path(".venv")): shutil.rmtree(self.path(".venv")) raise TempestSetupFailure(_("failed to install virtualenv"))