Repository: tox-dev/tox (python)

Issue:
Consider supporting 'py2' and 'py3' default environments
- Bitbucket: https://bitbucket.org/hpk42/tox/issue/348
- Originally reported by: [tobias.mcnulty](http://bitbucket.org/tobias.mcnulty)
- Originally created at: 2016-07-19T22:12:41.440


For packages where I want to test *some* version of python3 but I don't really care which one, support for `py2` and `py3` environments would be nice, e.g.:

	[testenv:py2]
	basepython = python2

	[testenv:py3]
	basepython = python3

I can create these easily enough myself, but thought I'd submit this issue in case anyone else would find it useful.


Pull request description:
fix #348 - add py2 and py3 as default envs

Patch:
diff --git a/CHANGELOG b/CHANGELOG
index 25c691f7..12828835 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,10 @@ unreleased
 - add support for py36 and py37 and add py36-dev and py37(nightly) to
   travis builds. Thanks John Vandenberg.
 
+- fix #348: add py2 and py3 as default environments pointing to
+  "python2" and "python3" basepython executables.  Also fix #347 by 
+  updating the list of default envs in the tox basic example.
+  Thanks Tobias McNulty.
 
 
 2.4.1
diff --git a/doc/example/basic.txt b/doc/example/basic.txt
index a8d074d2..5b0cf72f 100644
--- a/doc/example/basic.txt
+++ b/doc/example/basic.txt
@@ -31,15 +31,15 @@ you can run restrict the test run to the python2.6 environment.
 Available "default" test environments names are::
 
     py
-    py24
-    py25
+    py2
     py26
     py27
-    py30
-    py31
-    py32
+    py3
     py33
     py34
+    py35
+    py36
+    py37
     jython
     pypy
     pypy3
diff --git a/tox/config.py b/tox/config.py
index 38bfa1a9..dc0d4c2d 100644
--- a/tox/config.py
+++ b/tox/config.py
@@ -22,7 +22,7 @@ import tox
 iswin32 = sys.platform == "win32"
 
 default_factors = {'jython': 'jython', 'pypy': 'pypy', 'pypy3': 'pypy3',
-                   'py': sys.executable}
+                   'py': sys.executable, 'py2': 'python2', 'py3': 'python3'}
 for version in '26,27,32,33,34,35,36,37'.split(','):
     default_factors['py' + version] = 'python%s.%s' % tuple(version)
 


Test patch:
diff --git a/tests/test_config.py b/tests/test_config.py
index c488f583..6445a099 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -1480,7 +1480,7 @@ class TestGlobalOptions:
         assert str(env.basepython) == sys.executable
 
     def test_default_environments(self, tmpdir, newconfig, monkeypatch):
-        envs = "py26,py27,py32,py33,py34,py35,py36,py37,jython,pypy,pypy3"
+        envs = "py26,py27,py32,py33,py34,py35,py36,py37,jython,pypy,pypy3,py2,py3"
         inisource = """
             [tox]
             envlist = %s
@@ -1494,6 +1494,8 @@ class TestGlobalOptions:
                 assert env.basepython == "jython"
             elif name.startswith("pypy"):
                 assert env.basepython == name
+            elif name in ("py2", "py3"):
+                assert env.basepython == 'python' + name[-1]
             else:
                 assert name.startswith("py")
                 bp = "python%s.%s" % (name[2], name[3])