def test_venv(self):
        """ Verifies that _get_system_python_executable() works correctly
            in a 'venv' (Python 3 only feature).
        """

        # Get system-wide python bin seen from here first:
        pybin = _get_system_python_executable()
        # (this call was not a test, we really just need the path here)

        test_dir = tempfile.mkdtemp()
        try:
            # Check that in a venv/pyvenv, the system-wide python is returned:
            subprocess.check_output(
                [pybin, "-m", "venv", "--",
                 os.path.join(test_dir, "venv")])
            subprocess.check_output([
                os.path.join(test_dir, "venv", "bin", "pip"), "install", "-U",
                "pip"
            ])
            subprocess.check_output([
                os.path.join(test_dir, "venv", "bin", "pip"), "install", "-U",
                "pep517"
            ])
            sys_python_path = self.run__get_system_python_executable(
                os.path.join(test_dir, "venv", "bin", "python"))
            assert os.path.normpath(sys_python_path) == os.path.normpath(pybin)
        finally:
            shutil.rmtree(test_dir)
    def test_venv(self):
        """ Verifies that _get_system_python_executable() works correctly
            in a 'venv' (Python 3 only feature).
        """

        # Get system-wide python bin seen from here first:
        pybin = _get_system_python_executable()
        # (this call was not a test, we really just need the path here)

        test_dir = tempfile.mkdtemp()
        try:
            # Check that in a venv/pyvenv, the system-wide python is returned:
            subprocess.check_output([
                pybin, "-m", "venv", "--",
                os.path.join(test_dir, "venv")
            ])
            subprocess.check_output([
                os.path.join(test_dir, "venv", "bin", "pip"),
                "install", "-U", "pip"
            ])
            subprocess.check_output([
                os.path.join(test_dir, "venv", "bin", "pip"),
                "install", "-U", "pep517"
            ])
            sys_python_path = self.run__get_system_python_executable(
                os.path.join(test_dir, "venv", "bin", "python")
            )
            assert os.path.normpath(sys_python_path) == os.path.normpath(pybin)
        finally:
            shutil.rmtree(test_dir)
    def test_virtualenv(self):
        """ Verifies that _get_system_python_executable() works correctly
            if called with a python binary as found inside a virtualenv.
        """

        # Get system-wide python bin seen from here first:
        pybin = _get_system_python_executable()
        # (this call was not a test, we really just need the path here)

        test_dir = tempfile.mkdtemp()
        try:
            # Check that in a virtualenv, the system-wide python is returned:
            subprocess.check_output([
                pybin, "-m", "virtualenv", "--python=" + str(sys.executable),
                "--",
                os.path.join(test_dir, "virtualenv")
            ])
            subprocess.check_output([
                os.path.join(test_dir, "virtualenv", "bin", "pip"), "install",
                "-U", "pip"
            ])
            subprocess.check_output([
                os.path.join(test_dir, "virtualenv", "bin", "pip"), "install",
                "-U", "pep517<0.7.0"
            ])
            sys_python_path = self.run__get_system_python_executable(
                os.path.join(test_dir, "virtualenv", "bin", "python"))
            assert os.path.normpath(sys_python_path) == os.path.normpath(pybin)
        finally:
            shutil.rmtree(test_dir)
예제 #4
0
    def test_basic(self):
        # Tests function inside tox env with no further special setup.

        # Get system-wide python bin:
        pybin = _get_system_python_executable()

        # The python binary needs to match our major version to be correct:
        pyversion = subprocess.check_output([
            pybin, "-c", "import sys; print(sys.version)"
        ], stderr=subprocess.STDOUT).decode("utf-8", "replace")
        assert pyversion.strip() == sys.version.strip()
    def test_basic(self):
        # Tests function inside tox env with no further special setup.

        # Get system-wide python bin:
        pybin = _get_system_python_executable()

        # The python binary needs to match our major version to be correct:
        pyversion = subprocess.check_output([
            pybin, "-c", "import sys; print(sys.version)"
        ], stderr=subprocess.STDOUT).decode("utf-8", "replace")
        assert pyversion.strip() == sys.version.strip()
    def test_systemwide_python(self):
        # Get system-wide python bin seen from here first:
        pybin = _get_system_python_executable()
        # (this call was not a test, we really just need the path here)

        # Check that in system-wide python, the system-wide python is returned:
        # IMPORTANT: understand that this runs OUTSIDE of any virtualenv.
        try:
            p1 = os.path.normpath(
                self.run__get_system_python_executable(pybin))
            p2 = os.path.normpath(pybin)
            assert p1 == p2
        except RuntimeError as e:
            if "pep517" in str(e.args):
                # System python probably doesn't have pep517 available!
                # (remember this is not in a virtualenv)
                # Not much we can do in that case since pythonpackage needs it,
                # so we'll skip this particular check.
                pass
            else:
                raise
    def test_systemwide_python(self):
        # Get system-wide python bin seen from here first:
        pybin = _get_system_python_executable()
        # (this call was not a test, we really just need the path here)

        # Check that in system-wide python, the system-wide python is returned:
        # IMPORTANT: understand that this runs OUTSIDE of any virtualenv.
        try:
            p1 = os.path.normpath(
                self.run__get_system_python_executable(pybin)
            )
            p2 = os.path.normpath(pybin)
            assert p1 == p2
        except RuntimeError as e:
            if "pep517" in str(e.args):
                # System python probably doesn't have pep517 available!
                # (remember this is not in a virtualenv)
                # Not much we can do in that case since pythonpackage needs it,
                # so we'll skip this particular check.
                pass
            else:
                raise