summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernat Gabor <gaborjbernat@gmail.com>2018-10-28 12:55:31 +0000
committerBernat Gabor <gaborjbernat@gmail.com>2018-10-28 12:56:15 +0000
commit3bcb31b75276f6cb689e248fc17a5fb1546d2f3a (patch)
tree466d082619fc3001d2fcdccdcf6d3ef98cd90050
parentc5e0fb72c6336f0d26b7e101d817e15c9913962e (diff)
downloadvirtualenv-3bcb31b75276f6cb689e248fc17a5fb1546d2f3a.tar.gz
Jython support
-rw-r--r--.gitignore1
-rw-r--r--setup.py7
-rw-r--r--tests/test_cmdline.py19
-rw-r--r--tox.ini20
4 files changed, 31 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index 50e807f..a8478fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@ docs/_build
# python
*.py[cod]
+*$py.class
# tools
.tox
diff --git a/setup.py b/setup.py
index bb17aab..ec41735 100644
--- a/setup.py
+++ b/setup.py
@@ -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"))])
diff --git a/tox.ini b/tox.ini
index a4ffa7c..18f1443 100644
--- a/tox.ini
+++ b/tox.ini
@@ -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