summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2011-05-26 16:21:40 +0200
committerholger krekel <holger@merlinux.eu>2011-05-26 16:21:40 +0200
commite54d3635aaebd1f0d862501efcf7840ab37bf527 (patch)
tree54d748cc46886cc57cdf564e5bbb399000734206
parentcdc4e63241dd0f286a7cec6f676a1e93dd82e262 (diff)
downloadtox-e54d3635aaebd1f0d862501efcf7840ab37bf527.tar.gz
- rename environment to "setenv" to disambiguate a bit between test "environemnt" snad env-var settings
- some docs for the new "setenv" directive
-rw-r--r--doc/config.txt44
-rw-r--r--doc/example/basic.txt18
-rw-r--r--setup.py4
-rw-r--r--tests/test_config.py14
-rw-r--r--tests/test_venv.py4
-rw-r--r--tox/__init__.py2
-rw-r--r--tox/_config.py11
-rw-r--r--tox/_venv.py2
-rw-r--r--toxbootstrap.py2
9 files changed, 61 insertions, 40 deletions
diff --git a/doc/config.txt b/doc/config.txt
index 5cef3e2..180c41b 100644
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -79,26 +79,6 @@ Complete list of settings that you can put into ``testenv*`` sections:
change to this working directory when executing the test command.
**default**: ``{toxinidir}``
-.. confval:: args_are_paths=BOOL
-
- treat positional arguments passed to ``tox`` as file system paths
- and - if they exist on the filesystem - rewrite them according
- to the ``changedir``.
- **default**: True (due to the exists-on-filesystem check it's usually
- safe to try rewriting).
-
-.. confval:: envtmpdir=path
-
- defines a temporary directory for the virtualenv which will be cleared
- each time before the group of test commands is invoked.
- **default**: ``{envdir}/tmp``
-
-.. confval:: envlogdir=path
-
- defines a directory for logging where tox will put logs of tool
- invocation.
- **default**: ``{envdir}/log``
-
.. confval:: deps=MULTI-LINE-LIST
dependencies to be installed into the environment prior to project
@@ -111,6 +91,10 @@ Complete list of settings that you can put into ``testenv*`` sections:
deps = :myindex:pkg
+.. confval:: setenv=MULTI-LINE-LIST
+
+ each line contains a NAME=VALUE environment variable setting which
+ will be used for all command invocations.
.. confval:: recreate=True|False(default)
@@ -136,6 +120,26 @@ Complete list of settings that you can put into ``testenv*`` sections:
have access to globally installed packages. **default:** False, meaning
that virtualenvs will be created with ``--no-site-packages`` by default.
+.. confval:: args_are_paths=BOOL
+
+ treat positional arguments passed to ``tox`` as file system paths
+ and - if they exist on the filesystem - rewrite them according
+ to the ``changedir``.
+ **default**: True (due to the exists-on-filesystem check it's usually
+ safe to try rewriting).
+
+.. confval:: envtmpdir=path
+
+ defines a temporary directory for the virtualenv which will be cleared
+ each time before the group of test commands is invoked.
+ **default**: ``{envdir}/tmp``
+
+.. confval:: envlogdir=path
+
+ defines a directory for logging where tox will put logs of tool
+ invocation.
+ **default**: ``{envdir}/log``
+
.. confval:: indexserver
.. versionadded:: 0.9
diff --git a/doc/example/basic.txt b/doc/example/basic.txt
index 9bf0b68..7e93604 100644
--- a/doc/example/basic.txt
+++ b/doc/example/basic.txt
@@ -97,10 +97,26 @@ forcing re-creation of virtual environments
.. versionadded:: 0.9
-To for tox to recreate a (particular) virtual environment::
+To force tox to recreate a (particular) virtual environment::
tox --recreate -e py27
would trigger a complete reinstallation of the existing py27 environment
(or create it afresh if it doesn't exist).
+setting environment variables
+-------------------------------------------
+
+.. versionadded:: 1.0
+
+If you need to set an environment variable like ``PYTHONPATH`` you
+can use the ``setenv`` directive::
+
+ [testenv]
+ setenv =
+ PYTHONPATH = {toxinidir}/subdir
+
+When your test commands execute they will execute with
+a PYTHONPATH setting that will lead Python to also import
+from the ``subdir`` below the directory where your ``tox.ini``
+file resides.
diff --git a/setup.py b/setup.py
index 31bc427..71f72fe 100644
--- a/setup.py
+++ b/setup.py
@@ -33,7 +33,7 @@ def main():
description='virtualenv-based automation of test activities',
long_description=long_description,
url='http://codespeak.net/tox',
- version='1.0.dev3',
+ version='1.0.dev4',
license='GPLv2 or later',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
author='holger krekel',
@@ -57,4 +57,4 @@ def main():
)
if __name__ == '__main__':
- main()
+ main() \ No newline at end of file
diff --git a/tests/test_config.py b/tests/test_config.py
index 7d2db89..0934e9c 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -311,7 +311,7 @@ class TestConfigTestEnv:
assert envconfig.distribute == True
assert envconfig.sitepackages == False
assert envconfig.envlogdir == envconfig.envdir.join("log")
- assert envconfig.environment is None
+ assert envconfig.setenv is None
def test_specific_command_overrides(self, tmpdir, newconfig):
config = newconfig("""
@@ -352,19 +352,19 @@ class TestConfigTestEnv:
envconfig = config.envconfigs['python']
assert envconfig.envpython == envconfig.envbindir.join("jython")
- def test_environment_overrides(self, tmpdir, newconfig):
+ def test_setenv_overrides(self, tmpdir, newconfig):
config = newconfig("""
[testenv]
- environment =
+ setenv =
PYTHONPATH = something
ANOTHER_VAL=else
""")
assert len(config.envconfigs) == 1
envconfig = config.envconfigs['python']
- assert 'PYTHONPATH' in envconfig.environment
- assert 'ANOTHER_VAL' in envconfig.environment
- assert envconfig.environment['PYTHONPATH'] == 'something'
- assert envconfig.environment['ANOTHER_VAL'] == 'else'
+ assert 'PYTHONPATH' in envconfig.setenv
+ assert 'ANOTHER_VAL' in envconfig.setenv
+ assert envconfig.setenv['PYTHONPATH'] == 'something'
+ assert envconfig.setenv['ANOTHER_VAL'] == 'else'
def test_changedir_override(self, tmpdir, newconfig):
config = newconfig("""
diff --git a/tests/test_venv.py b/tests/test_venv.py
index 3def794..25f3d70 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -373,11 +373,11 @@ class TestVenvTest:
assert 'PIP_RESPECT_VIRTUALENV' not in os.environ
os.environ['PIP_RESPECT_VIRTUALENV'] = "1"
-def test_session_environment_added_to_pcall(mocksession, newconfig):
+def test_setenv_added_to_pcall(mocksession, newconfig):
config = newconfig([], """
[testenv:python]
commands=%s -V
- environment =
+ setenv =
ENV_VAR = value
""" % sys.executable)
mocksession._clearmocks()
diff --git a/tox/__init__.py b/tox/__init__.py
index 85b0fa3..9391450 100644
--- a/tox/__init__.py
+++ b/tox/__init__.py
@@ -1,5 +1,5 @@
#
-__version__ = '1.0.dev3'
+__version__ = '1.0.dev4'
class exception:
class Error(Exception):
diff --git a/tox/_config.py b/tox/_config.py
index 738da33..36ecfa3 100644
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -209,9 +209,9 @@ class parseini:
arg = vc.changedir.bestrelpath(origpath)
args.append(arg)
reader.addsubstitions(args)
- vc.environment = reader.getdict(section, 'environment')
- if not vc.environment:
- vc.environment = None
+ vc.setenv = reader.getdict(section, 'setenv')
+ if not vc.setenv:
+ vc.setenv = None
vc.commands = reader.getargvlist(section, "commands")
vc.deps = []
@@ -411,11 +411,12 @@ class IniReader:
def _replace_env(self, match):
envkey = match.group('substitution_value')
if not envkey:
- raise tox.exception.ConfigError('env: requires an environment variable name')
+ raise tox.exception.ConfigError(
+ 'env: requires an environment variable name')
if not envkey in os.environ:
raise tox.exception.ConfigError(
- "substitution env:%r: %r not found in environment" %
+ "substitution env:%r: unkown environment variable %r" %
(envkey, envkey))
return os.environ[envkey]
diff --git a/tox/_venv.py b/tox/_venv.py
index 8128be4..fcb8acb 100644
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -231,7 +231,7 @@ class VirtualEnv(object):
def test(self):
self.session.make_emptydir(self.envconfig.envtmpdir)
cwd = self.envconfig.changedir
- env = self.envconfig.environment
+ env = self.envconfig.setenv
if env:
env_arg = os.environ.copy()
env_arg.update(env)
diff --git a/toxbootstrap.py b/toxbootstrap.py
index 39fb2f6..d375fb1 100644
--- a/toxbootstrap.py
+++ b/toxbootstrap.py
@@ -58,7 +58,7 @@ ToDo
"""
-__version__ = '1.0.dev3'
+__version__ = '1.0.dev4'
import sys
import os