python/virtualenv/tests/test_cmdline.py
author Chris Manchester <cmanchester@mozilla.com>
Thu, 12 May 2016 11:55:59 -0700
changeset 323517 5d4213512f1af0c13fb721db996b6f440bb3e789
parent 315459 78babd21215d21389c7a8026f42db76a5f302af6
permissions -rw-r--r--
Bug 1257326 - Move MOZ_SERVICES_SYNC to Python configure. r=glandium MozReview-Commit-ID: DCDoSgHfwVY

import sys
import subprocess
import virtualenv
import pytest

VIRTUALENV_SCRIPT = virtualenv.__file__

def test_commandline_basic(tmpdir):
    """Simple command line usage should work"""
    subprocess.check_call([
        sys.executable,
        VIRTUALENV_SCRIPT,
        str(tmpdir.join('venv'))
    ])

def test_commandline_explicit_interp(tmpdir):
    """Specifying the Python interpreter should work"""
    subprocess.check_call([
        sys.executable,
        VIRTUALENV_SCRIPT,
        '-p', sys.executable,
        str(tmpdir.join('venv'))
    ])

# The registry lookups to support the abbreviated "-p 3.5" form of specifying
# a Python interpreter on Windows don't seem to work with Python 3.5. The
# registry layout is not well documented, and it's not clear that the feature
# is sufficiently widely used to be worth fixing.
# See https://github.com/pypa/virtualenv/issues/864
@pytest.mark.skipif("sys.platform == 'win32' and sys.version_info[:2] >= (3,5)")
def test_commandline_abbrev_interp(tmpdir):
    """Specifying abbreviated forms of the Python interpreter should work"""
    if sys.platform == 'win32':
        fmt = '%s.%s'
    else:
        fmt = 'python%s.%s'
    abbrev = fmt % (sys.version_info[0], sys.version_info[1])
    subprocess.check_call([
        sys.executable,
        VIRTUALENV_SCRIPT,
        '-p', abbrev,
        str(tmpdir.join('venv'))
    ])