diff options
| author | holger krekel <holger.krekel@gmail.com> | 2013-07-11 11:13:15 +0200 |
|---|---|---|
| committer | holger krekel <holger.krekel@gmail.com> | 2013-07-11 11:13:15 +0200 |
| commit | 47f06113a42edafc693caf9d97d8e724b3f11051 (patch) | |
| tree | 1bf502b2aa34017da26d267f0cb50d581285c249 | |
| parent | 72d6b90acf35e3a9b6dd8e039063028245fae658 (diff) | |
| parent | 08c2aaac036791e2be8b0e634d722ba0971b5216 (diff) | |
| download | tox-47f06113a42edafc693caf9d97d8e724b3f11051.tar.gz | |
Merged in lukaszb/tox (pull request #45)
Created initial documentation for development environments -- related with #101
| -rwxr-xr-x | CHANGELOG | 25 | ||||
| -rw-r--r-- | CONTRIBUTORS | 1 | ||||
| -rw-r--r-- | MANIFEST.in | 2 | ||||
| -rw-r--r-- | README.rst (renamed from README.txt) | 11 | ||||
| -rw-r--r-- | doc/conf.py | 2 | ||||
| -rw-r--r-- | doc/config.txt | 19 | ||||
| -rw-r--r-- | doc/example/basic.txt | 16 | ||||
| -rw-r--r-- | doc/index.txt | 3 | ||||
| -rw-r--r-- | doc/install.txt | 4 | ||||
| -rw-r--r-- | setup.py | 29 | ||||
| -rw-r--r-- | tests/test_config.py | 28 | ||||
| -rw-r--r-- | tests/test_venv.py | 31 | ||||
| -rw-r--r-- | tests/test_z_cmdline.py | 11 | ||||
| -rw-r--r-- | tox.ini | 12 | ||||
| -rw-r--r-- | tox/__init__.py | 2 | ||||
| -rw-r--r-- | tox/_config.py | 4 | ||||
| -rw-r--r-- | tox/_venv.py | 42 | ||||
| -rw-r--r-- | toxbootstrap.py | 9 |
18 files changed, 179 insertions, 72 deletions
@@ -1,17 +1,34 @@ -1.5.0.dev +1.5.1.dev ----------------- +- always unset PYTHONDONTWRITEBYTE because newer setuptools doesn't like it + +1.5.0 +----------------- + +- fix issue104: use setuptools by default, instead of distribute, + now that setuptools has distribute merged. + +- make sure test commands are searched first in the virtualenv + +- re-fix issue2 - add whitelist_externals to be used in ``[testenv*]`` + sections, allowing to avoid warnings for commands such as ``make``, + used from the commands value. + - fix issue97 - allow substitutions to reference from other sections (thanks Krisztian Fekete) - fix issue92 - fix {envsitepackagesdir} to actually work again +- show (test) command that is being executed, thanks + Lukasz Balcerzak + - re-license tox to MIT license - depend on virtualenv-1.9.1 -- use either --distribute or --setuptools depending - on "distribute" env config +- rename README.txt to README.rst to make bitbucket happier + 1.4.3 ----------------- @@ -59,7 +76,7 @@ - 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. + thanks to Barry Warsaw for both. 1.4.2 ----------------- diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 8db26dc..a6f2d71 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -4,6 +4,7 @@ contributions: Krisztian Fekete Marc Abramowitz Sridhar Ratnakumar +Barry Warsaw Chris Rose Jannis Leidl Ronny Pfannschmidt diff --git a/MANIFEST.in b/MANIFEST.in index 19df886..9fdb861 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ include CHANGELOG -include README.txt +include README.rst include CONTRIBUTORS include ISSUES.txt include LICENSE @@ -12,11 +12,16 @@ Tox as is a generic virtualenv_ management and test command line tool you can us * acting as a frontend to Continuous Integration servers, greatly reducing boilerplate and merging CI and shell-based testing. -For more information, docs and many examples please checkout: +For more information and the repository please checkout: + +- homepage: http://tox.testrun.org + +- repository: https://bitbucket.org/hpk42/tox + +have fun, - http://tox.testrun.org have fun, -holger krekel, May 2012 +holger krekel, May 2013 diff --git a/doc/conf.py b/doc/conf.py index c6e55ed..f643b48 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -48,7 +48,7 @@ copyright = u'2013, holger krekel and others' # built documents. # # The short X.Y version. -release = version = "1.4.3" +release = version = "1.5.0" # The full version, including alpha/beta/rc tags. # The language for content autogenerated by Sphinx. Refer to documentation diff --git a/doc/config.txt b/doc/config.txt index e30e57d..e5c937a 100644 --- a/doc/config.txt +++ b/doc/config.txt @@ -75,6 +75,16 @@ Complete list of settings that you can put into ``testenv*`` sections: For eventually performing a call to ``subprocess.Popen(args, ...)`` ``args`` are determined by splitting the whole command by whitespace. +.. confval:: whitelist_externals=MULTI-LINE-LIST + + each line specifies a command name (in glob-style pattern format) + which can be used in the ``commands`` section without triggering + a "not installed in virtualenv" warning. Example: if you use the + unix ``make`` for running tests you can list ``whitelist_externals=make`` + or ``whitelist_externals=/usr/bin/make`` if you want more precision. + If you don't want tox to issue a warning in any case, just use + ``whitelist_externals=*`` which will match all commands (not recommended). + .. confval:: changedir=path change to this working directory when executing the test command. @@ -115,9 +125,12 @@ Complete list of settings that you can put into ``testenv*`` sections: .. confval:: distribute=True|False - Set to ``False`` if you want to use setuptools_ instead of the default - distribute_ in the virtual environment. - **default:** True. + Set to ``True`` if you want to use distribute_ instead of the default + setuptools_ in the virtual environment. Prior to tox-1.5 the + default was True and now is False, meaning ``setuptools`` is used + (note that setuptools-0.7 merged with distribute). In future versions + of tox this option might be ignored and setuptools always chosen. + **default:** False. .. confval:: sitepackages=True|False diff --git a/doc/example/basic.txt b/doc/example/basic.txt index 6c92fac..031c4f9 100644 --- a/doc/example/basic.txt +++ b/doc/example/basic.txt @@ -44,6 +44,22 @@ Available "default" test environments names are:: However, you can also create your own test environment names, see some of the examples in :doc:`examples <../examples>`. +whitelisting a non-virtualenv commands +----------------------------------------------- + +.. versionadded:: 1.5 + +Sometimes you may want to use tools not contained in your +virtualenv such as ``make``, ``bash`` or others. To avoid +warnings you can use the ``whitelist_externals`` testenv +configuration:: + + # content of tox.ini + [testenv] + whitelist_externals = make + /bin/bash + + .. _virtualenv: http://pypi.python.org/pypi/virtualenv .. _multiindex: diff --git a/doc/index.txt b/doc/index.txt index 20d65d4..1838b3b 100644 --- a/doc/index.txt +++ b/doc/index.txt @@ -1,7 +1,8 @@ Welcome to the tox automation project =============================================== -.. note:: Upcoming: `professional testing with pytest and tox <http://www.python-academy.com/courses/specialtopics/python_course_testing.html>`_ , 24th-26th June 2013, Leipzig. +.. + Upcoming: `professional testing with pytest and tox <http://www.python-academy.com/courses/specialtopics/python_course_testing.html>`_ , 24th-26th June 2013, Leipzig. vision: standardize testing in Python --------------------------------------------- diff --git a/doc/install.txt b/doc/install.txt index 6394920..c794692 100644 --- a/doc/install.txt +++ b/doc/install.txt @@ -4,13 +4,13 @@ tox installation Install info in a nutshell ---------------------------------- -**Pythons**: CPython 2.4-3.2, Jython-2.5.1, pypy-1.5 +**Pythons**: CPython 2.4-3.3, Jython-2.5.1, pypy-1.9ff **Operating systems**: Linux, Windows, OSX, Unix **Installer Requirements**: setuptools_ or Distribute_ -**License**: GPLv2 or later +**License**: MIT license **hg repository**: http://bitbucket.org/hpk42/tox @@ -2,29 +2,6 @@ import sys from setuptools import setup from setuptools.command.test import test as TestCommand -long_description = """ -What is Tox? -========================== - -Tox as is a generic virtualenv management and test command line tool you can -use for: - -* checking your package installs correctly with different - Python versions and interpreters - -* running your tests in each of the - environments, configuring your test tool of choice - -* acting as a frontend to Continuous Integration - servers, greatly reducing boilerplate and merging - CI and shell-based testing. - -For more information, docs and many examples please checkout the `home page`_: - - http://tox.testrun.org/ - -.. _`home page`: http://tox.testrun.org/ -""" class Tox(TestCommand): @@ -41,15 +18,15 @@ class Tox(TestCommand): def main(): version = sys.version_info[:2] - install_requires = ['virtualenv>=1.9.1', 'py>=1.4.13', ] + install_requires = ['virtualenv>=1.9.1', 'py>=1.4.15', ] if version < (2, 7) or (3, 0) <= version <= (3, 1): install_requires += ['argparse'] setup( name='tox', description='virtualenv-based automation of test activities', - long_description=long_description, + long_description=open("README.rst").read(), url='http://tox.testrun.org/', - version='1.5.dev7', + version='1.5.1.dev1', license='http://opensource.org/licenses/MIT', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], author='holger krekel', diff --git a/tests/test_config.py b/tests/test_config.py index e3e5c62..0602ff1 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -382,7 +382,7 @@ class TestConfigTestEnv: envconfig = config.envconfigs['python'] assert envconfig.commands == [["xyz", "--abc"]] assert envconfig.changedir == config.setupdir - assert envconfig.distribute == True + assert envconfig.distribute == False assert envconfig.sitepackages == False assert envconfig.envlogdir == envconfig.envdir.join("log") assert envconfig.setenv is None @@ -398,6 +398,24 @@ class TestConfigTestEnv: envconfig = config.envconfigs['py'] assert envconfig.commands == [["abc"]] + def test_whitelist_externals(self, tmpdir, newconfig): + config = newconfig(""" + [testenv] + whitelist_externals = xyz + commands=xyz + [testenv:x] + + [testenv:py] + whitelist_externals = xyz2 + commands=abc + """) + assert len(config.envconfigs) == 2 + envconfig = config.envconfigs['py'] + assert envconfig.commands == [["abc"]] + assert envconfig.whitelist_externals == ["xyz2"] + envconfig = config.envconfigs['x'] + assert envconfig.whitelist_externals == ["xyz"] + def test_changedir(self, tmpdir, newconfig): config = newconfig(""" [testenv] @@ -847,8 +865,10 @@ class TestIndexServer: """ config = newconfig([], inisource) homedir = str(py.path.local._gethomedir()) - assert config.indexserver['default'].url == "file://{h}/.pip/downloads/simple".format(h=homedir) - assert config.indexserver['local1'].url == config.indexserver['default'].url + expected = "file://%s/.pip/downloads/simple" % homedir + assert config.indexserver['default'].url == expected + assert config.indexserver['local1'].url == \ + config.indexserver['default'].url class TestParseEnv: @@ -904,8 +924,6 @@ class TestCmdInvocation: *docs* """) - @py.test.mark.xfail("sys.version_info < (2,6)", - reason="virtualenv3 cannot be imported") def test_config_specific_ini(self, tmpdir, cmd): ini = tmpdir.ensure("hello.ini") result = cmd.run("tox", "-c", ini, "--showconfig") diff --git a/tests/test_venv.py b/tests/test_venv.py index e9d9519..e66aba9 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -102,6 +102,20 @@ def test_create(monkeypatch, mocksession, newconfig): assert interp == venv.getconfigexecutable() assert venv.path_config.check(exists=False) +@pytest.mark.skipif("sys.platform == 'win32'") +def test_commandpath_venv_precendence(tmpdir, monkeypatch, + mocksession, newconfig): + config = newconfig([], """ + [testenv:py123] + """) + envconfig = config.envconfigs['py123'] + venv = VirtualEnv(envconfig, session=mocksession) + tmpdir.ensure("easy_install") + monkeypatch.setenv("PATH", str(tmpdir), prepend=os.pathsep) + envconfig.envbindir.ensure("easy_install") + p = venv.getcommandpath("easy_install") + assert py.path.local(p).relto(envconfig.envbindir), p + def test_create_distribute(monkeypatch, mocksession, newconfig): config = newconfig([], """ [testenv:py123] @@ -295,6 +309,21 @@ def test_install_command_not_installed(newmocksession, monkeypatch): mocksession.report.expect("warning", "*test command found but not*") assert venv.status == "commands failed" +def test_install_command_whitelisted(newmocksession, monkeypatch): + mocksession = newmocksession(['--recreate'], """ + [testenv] + whitelist_externals = py.test + xy* + commands= + py.test + xyz + """) + venv = mocksession.getenv('python') + venv.test() + mocksession.report.expect("warning", "*test command found but not*", + invert=True) + assert venv.status == "commands failed" + @pytest.mark.skipif("not sys.platform.startswith('linux')") def test_install_command_not_installed(newmocksession): mocksession = newmocksession(['--recreate'], """ @@ -438,7 +467,7 @@ class TestCreationConfig: venv = VirtualEnv(envconfig, session=mocksession) venv.update() cconfig = venv._getliveconfig() - cconfig.distribute = False + cconfig.distribute = True cconfig.writeconfig(venv.path_config) mocksession._clearmocks() venv.update() diff --git a/tests/test_z_cmdline.py b/tests/test_z_cmdline.py index f7ecee2..0208443 100644 --- a/tests/test_z_cmdline.py +++ b/tests/test_z_cmdline.py @@ -2,7 +2,7 @@ import tox import py import pytest import sys -from conftest import ReportExpectMock +from tox._pytestplugin import ReportExpectMock pytest_plugins = "pytester" @@ -382,6 +382,15 @@ def test_env_PYTHONDONTWRITEBYTECODE(initproj, cmd, monkeypatch): "*create*", ]) +def test_env_VIRTUALENV_PYTHON(initproj, cmd, monkeypatch): + initproj("example123", filedefs={'tox.ini': ''}) + monkeypatch.setenv("VIRTUALENV_PYTHON", '/FOO') + result = cmd.run("tox", "-v", "--notest") + assert not result.ret, result.stdout.lines + result.stdout.fnmatch_lines([ + "*create*", + ]) + def test_sdistonly(initproj, cmd): initproj("example123", filedefs={'tox.ini': """ """}) @@ -1,20 +1,22 @@ [tox] envlist=py27,py26,py25,py32,py33,docs,pypy -indexserver = - testrun = http://pypi.testrun.org - pypi = https://pypi.python.org/simple [testenv:X] commands=echo {posargs} [testenv] -commands=py.test --junitxml={envlogdir}/junit-{envname}.xml {posargs} +commands=py.test --instafail --junitxml={envlogdir}/junit-{envname}.xml {posargs} deps=pytest==2.3.4 + pytest-instafail + +[testenv:py25] +setenvs = + PIP_INSECURE=True [testenv:docs] basepython=python changedir=doc -deps=:pypi:sphinx +deps=sphinx {[testenv]deps} commands= py.test -v \ diff --git a/tox/__init__.py b/tox/__init__.py index 635b69b..ed82f37 100644 --- a/tox/__init__.py +++ b/tox/__init__.py @@ -1,5 +1,5 @@ # -__version__ = '1.5.dev7' +__version__ = '1.5.1.dev1' class exception: class Error(Exception): diff --git a/tox/_config.py b/tox/_config.py index 3b6c217..78d5fcd 100644 --- a/tox/_config.py +++ b/tox/_config.py @@ -291,6 +291,8 @@ class parseini: vc.setenv = None vc.commands = reader.getargvlist(section, "commands") + vc.whitelist_externals = reader.getlist(section, + "whitelist_externals") vc.deps = [] for depline in reader.getlist(section, "deps"): m = re.match(r":(\w+):\s*(\S+)", depline) @@ -301,7 +303,7 @@ class parseini: name = depline.strip() ixserver = None vc.deps.append(DepConfig(name, ixserver)) - vc.distribute = reader.getbool(section, "distribute", True) + vc.distribute = reader.getbool(section, "distribute", False) vc.sitepackages = reader.getbool(section, "sitepackages", False) vc.downloadcache = None downloadcache = os.environ.get("PIP_DOWNLOAD_CACHE", None) diff --git a/tox/_venv.py b/tox/_venv.py index 79e38ed..f23557a 100644 --- a/tox/_venv.py +++ b/tox/_venv.py @@ -74,21 +74,38 @@ class VirtualEnv(object): p = cwd.join(name) if p.check(): return str(p) + p = None + if venv: + p = py.path.local.sysfind(name, paths=[self.envconfig.envbindir]) + if p is not None: + return p p = py.path.local.sysfind(name) if p is None: - raise tox.exception.InvocationError("could not find executable %r" - % (name,)) - if p.relto(self.envconfig.envdir): - return p + raise tox.exception.InvocationError( + "could not find executable %r" % (name,)) + # p is not found in virtualenv script/bin dir if venv: - self.session.report.warning( - "test command found but not installed in testenv\n" - " cmd: %s\n" - " env: %s\n" - "Maybe forgot to specify a dependency?" % (p, - self.envconfig.envdir)) + if not self.is_allowed_external(p): + self.session.report.warning( + "test command found but not installed in testenv\n" + " cmd: %s\n" + " env: %s\n" + "Maybe forgot to specify a dependency?" % (p, + self.envconfig.envdir)) return str(p) # will not be rewritten for reporting + def is_allowed_external(self, p): + tryadd = [""] + if sys.platform == "win32": + tryadd += [os.path.normcase(x) + for x in os.environ['PATHEXT'].split(os.pathsep)] + p = py.path.local(os.path.normcase(str(p))) + for x in self.envconfig.whitelist_externals: + for add in tryadd: + if p.fnmatch(x + add): + return True + return False + def _ispython3(self): return "python3" in str(self.envconfig.basepython) @@ -284,6 +301,11 @@ class VirtualEnv(object): def _pcall(self, args, venv=True, cwd=None, extraenv={}, action=None, redirect=True): + for name in ("VIRTUALENV_PYTHON", "PYTHONDONTWRITEBYTECODE"): + try: + del os.environ[name] + except KeyError: + pass assert cwd cwd.ensure(dir=1) old = self.patchPATH() diff --git a/toxbootstrap.py b/toxbootstrap.py index bb926e1..cae20d2 100644 --- a/toxbootstrap.py +++ b/toxbootstrap.py @@ -58,7 +58,7 @@ ToDo """ -__version__ = '1.5.dev7' +__version__ = '1.5.1.dev1' import sys import os @@ -192,7 +192,7 @@ def cmdline(argv=None): # XXX: we use --no-site-packages because: if tox is installed in global # site-packages, then pip will not install it locally. ideal fix for # this should be to first look for tox in the global scripts/ directory - run('%s virtualenv.py --no-site-packages --distribute %s' % + run('%s virtualenv.py --no-site-packages --setuptools %s' % (sys.executable, TENV)) logging.info("removing virtualenv.py script after bootstrap venv creation") for x in ('', 'o', 'c'): @@ -209,11 +209,6 @@ def cmdline(argv=None): # install/upgrade tox itself if USETOXDEV: - if 'PIP_DOWNLOAD_CACHE' in os.environ: - cache = "" - else: - cache = "--download-cache=_download" - ensuredir('_download') run('%s install -q -i http://pypi.testrun.org ' '--upgrade %s tox' % (pip, cache)) elif any([ |
