Anonymous avatar Anonymous committed ce71f09 Draft Merge

Update my fork; merge from ssh://hg@bitbucket.org/hpk42/tox

Comments (0)

Files changed (13)

 1.4.3.dev
 -----------------
 
+- fix #48 - win32 detection of pypy and other interpreters that are on PATH
+  (thanks Gustavo Picon)
+
 - fix grouping of index servers, it is now done by name instead of 
   indexserver url, allowing to use it to separate dependencies
   into groups even if using the same default indexserver.
 
+- look for "tox.ini" files in parent dirs of current dir (closes #34)
+
+- the "py" environment now by default uses the current interpreter
+  (sys.executable) make tox' own setup.py test execute tests with it
+  (closes #46)
+
+- change tests to not rely on os.path.expanduser (closes #60),
+  also make mock session return args[1:] for more precise checking (closes #61)
+  thanks to Barry Warszaw for both.
+
 1.4.2
 -----------------
 
+introduce package and setup.py less sdist creation
+-----------------------------------------------------------
+
+Example sections for tox itself::
+
+    [pkgdef] 
+    basename = pytest
+    description = virtualenv-based automation of test activities
+    authors = holger krekel <holger@merlinux.eu>
+    url = http://tox.testrun.org
+    entry_points = console_scripts: tox=tox:cmdline
+    requires = py
+    packages = 
+    preuploadenvs = sphinx 
+
+    classifiers=
+        Development Status :: 6 - Mature
+        Intended Audience :: Developers
+        License :: OSI Approved :: MIT License
+        Topic :: Software Development :: Testing
+        Topic :: Software Development :: Libraries
+        Topic :: Utilities
+
+This would generate three different packages:
+
+- the main one containing the app with the specified description, etc.
+  It has a test-requires pointing to the test package,
+  which classifiers
+- the test package only containing the tests and setup.py
+  depending on the main package and all requirements collected from the
+  testenv
+- the doc package containing generated html and txt files
+  (to be installable via a setup.py as well?)
+
+Here is what happens when tox is invoked now:
+
+- version gets auto-incremented (in setup.py and $PACKAGE/__init__.py files)
+- main setup.py generated, files copied, sdist generated
+- test setup.py generated, files copied, sdist generated
+- doc setup.py generated, doc environment run, files copied, sdist generated
+
+- if --upload is specified, all packages are uploaded under 
+  their respective names:
+  tox-VER
+  tests-tox-VER
+  docs-tox-VER
+
+- tox --sync creates a test result file for the tests-tox-VER run
+  and uploads it to testrun.org -- .tox/projectkeys contains a file that
+  was created by visiting testrun.org and registering/logging in.
+
+- download toxslave and execute it:
+
+    toxslave --userkey=... [--project tox]
+
+  which will query testrun.org for outstanding testruns
+  [for the tox project], download packages, execute them 
+  and report back to the server
+
+merge tox and detox?
+----------------------------------------------------------------
+
+maybe it's time to merge it?
+
+http://lists.idyll.org/pipermail/testing-in-python/2012-October/005205.html
+pyc files / test distributions
+-----------------------------------------------------------
+
+investigate pyc cleaning, see
+
+http://lists.idyll.org/pipermail/testing-in-python/2012-October/005205.html
+
+
 allow config overlays
 -----------------------------------------------------------
 
-The execnet package is released under the provisions of the Gnu Public
-License (GPL), version 2 or later.  
+The tox package is released under the provisions of the GNU General
+Public License (GPL), version 2 or later.  
 
 See http://www.fsf.org/licensing/licenses/ for more information.
 
 envlist setting
 +++++++++++++++++++++++++
 
-Determining the environment list that ``tox`` is to operate one
+Determining the environment list that ``tox`` is to operate on
 happens in this order:
 
 * command line option ``-eENVLIST``
 class Tox(TestCommand):
     def finalize_options(self):
         TestCommand.finalize_options(self)
-        self.test_args = []
+        self.test_args = ["-v", "-epy"]
         self.test_suite = True
 
     def run_tests(self):
         description='virtualenv-based automation of test activities',
         long_description=long_description,
         url='http://tox.testrun.org/',
-        version='1.4.3.dev0',
+        version='1.4.3.dev1',
         license='GPLv2 or later',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
         author='holger krekel',

tests/conftest.py

 
 class pcallMock:
     def __init__(self, args, cwd, env, stdout, stderr, shell):
-        self.args = args
+        self.arg0 = args[0]
+        self.args = args[1:]
         self.cwd = cwd
         self.env = env
         self.stdout = stdout

tests/test_config.py

 
 import py
 from tox._config import IniReader, CommandParser
+from tox._config import parseconfig
 
 class TestVenvConfig:
     def test_config_parsing_minimal(self, tmpdir, newconfig):
         """ % tmpdir)
         assert config.toxworkdir == tmpdir
 
+class TestParseconfig:
+    def test_search_parents(self, tmpdir):
+        b = tmpdir.mkdir("a").mkdir("b")
+        toxinipath = tmpdir.ensure("tox.ini")
+        old = b.chdir()
+        try:
+            config = parseconfig([])
+        finally:
+            old.chdir()
+        assert config.toxinipath == toxinipath
+
 class TestIniParser:
     def test_getdefault_single(self, tmpdir, newconfig):
         config = newconfig("""
         assert argv[3][0] == conf.envbindir
         assert argv[4][0] == conf.envtmpdir
         assert argv[5][0] == conf.envpython
-        assert argv[6][0] == os.path.expanduser("~")
+        assert argv[6][0] == str(py.path.local._gethomedir())
         assert argv[7][0] == config.homedir.join(".tox", "distshare")
         assert argv[8][0] == conf.envlogdir
 
         config = newconfig(["-eALL"], inisource)
         assert config.envlist == ['py26', 'py27', 'py31']
 
+    def test_py_venv(self, tmpdir, newconfig, monkeypatch):
+        config = newconfig(["-epy"], "")
+        env = config.envconfigs['py']
+        assert str(env.basepython) == sys.executable
+
     def test_default_environments(self, tmpdir, newconfig, monkeypatch):
         envs = "py24,py25,py26,py27,py30,py31,py32,jython,pypy"
         inisource = """
         assert tox.__version__ in stdout
         assert "imported from" in stdout
 
-    def test_unkonwn_ini(self, cmd):
-        result = cmd.run("tox")
-        assert result.ret
-        result.stderr.fnmatch_lines([
-            "*tox.ini*does not exist*",
-        ])
-
     @py.test.mark.xfail("sys.version_info < (2,6)",
         reason="virtualenv3 cannot be imported")
     def test_config_specific_ini(self, tmpdir, cmd):
         result = cmd.run("tox")
         assert result.ret
         result.stderr.fnmatch_lines([
-            "*ERROR*tox.ini*does not exist*",
+            "*ERROR*tox.ini*not*found*",
         ])
 
-
 class TestCommandParser:
 
     def test_command_parser_for_word(self):

tests/test_venv.py

 import pytest
 import os, sys
 from tox._venv import VirtualEnv, CreationConfig, getdigest
+from tox._venv import find_executable
 
 #def test_global_virtualenv(capfd):
 #    v = VirtualEnv()
 def test_getdigest(tmpdir):
     assert getdigest(tmpdir) == "0"*32
 
+@pytest.mark.skipif("sys.platform != 'win32'")
 def test_locate_via_py(monkeypatch):
     from tox._venv import locate_via_py
     class PseudoPy:
     assert locate_via_py('3', '2') == sys.executable
 
 def test_find_executable():
-    from tox._venv import find_executable
     p = find_executable(sys.executable)
     assert p == py.path.local(sys.executable)
     for ver in [""] + "2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3".split():
         stdout, stderr = popen.communicate()
         assert ver in py.builtin._totext(stderr, "ascii")
 
+def test_find_executable_extra(monkeypatch):
+    @staticmethod
+    def sysfind(x):
+        return "hello"
+    monkeypatch.setattr(py.path.local, "sysfind", sysfind)
+    t = find_executable("qweqwe")
+    assert t == "hello"
+
 def test_getsupportedinterpreter(monkeypatch, newconfig, mocksession):
     config = newconfig([], """
         [testenv:python]
 
 [testenv]
 commands=py.test --junitxml={envlogdir}/junit-{envname}.xml {posargs}
-deps=pytest
-     py
+deps=pytest==2.3.2
 
 [testenv:docs]
 basepython=python
 #
-__version__ = '1.4.3.dev0'
+__version__ = '1.4.3.dev1'
 
 class exception:
     class Error(Exception):
 import tox
 
 defaultenvs = {'jython': 'jython', 'pypy': 'pypy'}
-for _name in "py24,py25,py26,py27,py30,py31,py32,py33".split(","):
-    defaultenvs[_name] = "python%s.%s" %(_name[2], _name[3])
+for _name in "py,py24,py25,py26,py27,py30,py31,py32,py33,py34".split(","):
+    if _name == "py":
+        basepython = sys.executable
+    else:
+        basepython = "python" + ".".join(_name[2:4])
+    defaultenvs[_name] = basepython
 
 def parseconfig(args=None, pkg=None):
     if args is None:
     opts = parser.parse_args(args)
     config = Config()
     config.option = opts
-    parseini(config)
+    basename = config.option.configfile
+    if os.path.isabs(basename):
+        inipath = py.path.local(basename)
+    else:
+        for path in py.path.local().parts(reverse=True):
+            inipath = path.join(basename)
+            if inipath.check():
+                break
+        else:
+            feedback("toxini file %r not found" %(basename), sysexit=True)
+    parseini(config, inipath)
     return config
 
 def feedback(msg, sysexit=False):
         help="show configuration information. ")
     parser.add_argument("-c", action="store", default="tox.ini",
         dest="configfile",
-        help="use the specified config file.")
+        help="use the specified config file name.")
     parser.add_argument("-e", action="store", dest="env",
         metavar="envlist",
         help="work against specified environments (ALL selects all).")
 testenvprefix = "testenv:"
 
 class parseini:
-    def __init__(self, config):
-        config.option.configfile = py.path.local(config.option.configfile)
-        config.toxinipath = config.option.configfile
+    def __init__(self, config, inipath):
+        config.toxinipath = inipath
         config.toxinidir = toxinidir = config.toxinipath.dirpath()
 
-        if not config.toxinipath.check():
-            feedback("toxini file %r does not exist" %(
-                str(config.toxinipath)), sysexit=True)
         self._cfg = py.iniconfig.IniConfig(config.toxinipath)
         config._cfg = self._cfg
         self.config = config
                     return exe
 
     def find_executable(name):
-        p = py.path.local(name)
-        if p.check(file=1):
+        p = py.path.local.sysfind(name)
+        if p:
             return p
         actual = None
         # Is this a standard PythonX.Y name?
 
 """
 
-__version__ = '1.4.3.dev0'
+__version__ = '1.4.3.dev1'
 
 import sys
 import os
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.