diff options
author | Bernat Gabor <gaborjbernat@gmail.com> | 2018-10-28 12:55:31 +0000 |
---|---|---|
committer | Bernat Gabor <gaborjbernat@gmail.com> | 2018-10-28 12:56:15 +0000 |
commit | 3bcb31b75276f6cb689e248fc17a5fb1546d2f3a (patch) | |
tree | 466d082619fc3001d2fcdccdcf6d3ef98cd90050 | |
parent | c5e0fb72c6336f0d26b7e101d817e15c9913962e (diff) | |
download | virtualenv-3bcb31b75276f6cb689e248fc17a5fb1546d2f3a.tar.gz |
Jython support
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | setup.py | 7 | ||||
-rw-r--r-- | tests/test_cmdline.py | 19 | ||||
-rw-r--r-- | tox.ini | 20 |
4 files changed, 31 insertions, 16 deletions
@@ -10,6 +10,7 @@ docs/_build # python *.py[cod] +*$py.class # tools .tox @@ -120,7 +120,12 @@ setup( package_data={"virtualenv_support": ["*.whl"]}, python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", extras_require={ - "testing": ["mock", "pytest >= 3.0.0, <4", "pytest-cov >= 2.5.1, <3", "pytest-timeout >= 1.3.0, <2"], + "testing": [ + 'mock;python_version<"3.3"', + "pytest >= 3.0.0, <4", + "coverage >= 4.5.0, <5", + 'pytest-timeout >= 1.3.0, <2; platform_python_implementation!="Jython"', + ], "docs": ["sphinx >= 1.8.0, < 2"], }, **setup_params diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 667be61..b82b426 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -1,3 +1,4 @@ +import os import subprocess import sys @@ -5,12 +6,20 @@ import pytest import virtualenv -VIRTUALENV_SCRIPT = virtualenv.__file__ + +def get_src(path): + base, _ = os.path.splitext(path) + if virtualenv.is_jython and base.endswith("$py"): + base = base[:-3] # strip away Jython ext + return "{}.py".format(base) + + +VIRTUALENV_SCRIPT = get_src(virtualenv.__file__) def test_commandline_basic(tmpdir): """Simple command line usage should work""" - subprocess.check_call([sys.executable, VIRTUALENV_SCRIPT, str(tmpdir.join("venv"))]) + subprocess.check_output([sys.executable, VIRTUALENV_SCRIPT, str(tmpdir.join("venv"))], stderr=subprocess.STDOUT) def test_commandline_explicit_interp(tmpdir): @@ -26,9 +35,5 @@ def test_commandline_explicit_interp(tmpdir): @pytest.mark.skipif("sys.platform == 'win32' and sys.version_info[:1] >= (3,)") 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]) + abbrev = "{}{}.{}".format("" if sys.platform == "win32" else "python", *sys.version_info[0:2]) subprocess.check_call([sys.executable, VIRTUALENV_SCRIPT, "-p", abbrev, str(tmpdir.join("venv"))]) @@ -1,6 +1,6 @@ [tox] minversion = 3.3.0 -envlist = fix_lint, embed, py{27,34,35,36,37}, pypy{,3}, cross_python{2,3}, docs, package_readme +envlist = fix_lint, embed, py{27,34,35,36,37}, pypy{,3}, jython, cross_python{2,3}, docs, package_readme isolated_build = true skip_missing_interpreters = true @@ -9,18 +9,22 @@ description = run tests with {basepython} setenv = PIP_DISABLE_VERSION_CHECK = 1 COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}} extras = testing -commands = pytest {posargs:\ - --cov=virtualenv \ - --cov-config="{toxinidir}/tox.ini" \ - --timeout=180 \ - --junitxml={env:JUNIT_XML_FILE:{toxworkdir}/.test.{envname}.xml} \ - . } +commands = coverage run --source=virtualenv \ + --rcfile="{toxinidir}/tox.ini" \ + {envbindir}/pytest tests + {posargs:\ + --junitxml={env:JUNIT_XML_FILE:{toxworkdir}/.test.{envname}.xml} + !jython: --timeout=180 \ + } + coverage combine --rcfile="{toxinidir}/tox.ini" + !jython: coverage report -m --rcfile="{toxinidir}/tox.ini" [testenv:.package] deps = [coverage:run] branch = false +parallel = true [coverage:report] skip_covered = True @@ -45,7 +49,7 @@ passenv = DIFF_AGAINST setenv = COVERAGE_FILE={toxworkdir}/.coverage commands = coverage erase --rcfile="{toxinidir}/tox.ini" coverage combine --rcfile="{toxinidir}/tox.ini" - coverage report -m --rcfile="{toxinidir}/tox.ini" + coverage report --show-missing --rcfile="{toxinidir}/tox.ini" coverage xml -o {toxworkdir}/coverage.xml --rcfile="{toxinidir}/tox.ini" coverage html -d {toxworkdir}/htmlcov --rcfile="{toxinidir}/tox.ini" diff-cover --compare-branch {env:DIFF_AGAINST:origin/master} {toxworkdir}/coverage.xml |