diff options
| author | holger krekel <holger.krekel@gmail.com> | 2013-07-16 17:01:38 +0200 |
|---|---|---|
| committer | holger krekel <holger.krekel@gmail.com> | 2013-07-16 17:01:38 +0200 |
| commit | eabb1118fd41225598a2b89e8c1d6e52023bfb44 (patch) | |
| tree | c3dbba46947f6592df0b851fd956dbb73fa7b020 | |
| parent | 115d97c0b0e7befc1dcbb707c0e554164939950f (diff) | |
| parent | d14665a3aa4785e790c3d6a9a73d4089a2fa4bc0 (diff) | |
| download | tox-eabb1118fd41225598a2b89e8c1d6e52023bfb44.tar.gz | |
Merged in mordred/configurable-hooks (pull request #49)
Make software installation more configurable
| -rw-r--r-- | doc/config.txt | 9 | ||||
| -rw-r--r-- | doc/example/devenv.txt | 58 | ||||
| -rw-r--r-- | doc/examples.txt | 1 | ||||
| -rw-r--r-- | doc/index.txt | 3 | ||||
| -rw-r--r-- | tests/test_config.py | 30 |
5 files changed, 99 insertions, 2 deletions
diff --git a/doc/config.txt b/doc/config.txt index 356530a..c0f262a 100644 --- a/doc/config.txt +++ b/doc/config.txt @@ -178,6 +178,15 @@ Complete list of settings that you can put into ``testenv*`` sections: (including when installing the project sdist package). +.. confval:: envdir + + .. versionadded:: 1.5 + + User can set specific path for environment. If path would not be absolute it + would be treated as relative to ``{toxinidir}``. **default**: + ``{toxworkdir}/{envname}`` + + Substitutions --------------------- diff --git a/doc/example/devenv.txt b/doc/example/devenv.txt new file mode 100644 index 0000000..3561c3e --- /dev/null +++ b/doc/example/devenv.txt @@ -0,0 +1,58 @@ + +Development environment +======================= + +Tox can be used to prepare development virtual environment for local projects. +This feature can be useful in order to preserve environment across team members +working on same project. It can be also used by deployment tools to prepare +proper environments. + + +Configuration +------------- + +Firstly, you need to prepare configuration for your development environment. In +order to do that, we must define proper section at ``tox.ini`` file and tell at +what directory environment should be created. Moreover, we need to specify +python version that should be picked:: + + [testenv:devenv] + envdir = devenv + basepython = python2.7 + commands = + deps = + + +Actually, you can configure a lot more, those are the only required settings. +In example you can add ``deps`` and ``commands`` settings. Here, we tell tox +not to pick ``commands`` or ``deps`` from base ``testenv`` configuration. + + +Creating development environment +-------------------------------- + +Once ``devenv`` section is defined we can instrument tox to create our +environment:: + + tox -e devenv + +This will create an environment at path specified by ``envdir`` under +``[testenv:devenv]`` section. + + +Full configuration example +-------------------------- + +Let's say we want our development environment sit at ``devenv`` and pull +packages from ``requirements.txt`` file which we create at the same directory +as ``tox.ini`` file. We also want to speciy Python version to be 2.7. + +Here is example configuration for that:: + + [testenv:devenv] + envdir = devenv + basepython = python2.7 + deps = + commands = + pip install -r requirements.txt + diff --git a/doc/examples.txt b/doc/examples.txt index 523a211..a3e9d91 100644 --- a/doc/examples.txt +++ b/doc/examples.txt @@ -11,4 +11,5 @@ tox configuration and usage examples example/nose.txt example/general.txt example/jenkins.txt + example/devenv.txt diff --git a/doc/index.txt b/doc/index.txt index 1838b3b..7ec9360 100644 --- a/doc/index.txt +++ b/doc/index.txt @@ -1,8 +1,7 @@ Welcome to the tox automation project =============================================== -.. - Upcoming: `professional testing with pytest and tox <http://www.python-academy.com/courses/specialtopics/python_course_testing.html>`_ , 24th-26th June 2013, Leipzig. +.. note:: second training: `professional testing with Python <http://www.python-academy.com/courses/specialtopics/python_course_testing.html>`_ , 25-27th November 2013, Leipzig. vision: standardize testing in Python --------------------------------------------- diff --git a/tests/test_config.py b/tests/test_config.py index 037fc26..0602ff1 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -44,6 +44,36 @@ class TestVenvConfig: assert dep2.indexserver.name == "xyz" assert dep2.indexserver.url == "xyz_repo" + def test_envdir_set_manually(self, tmpdir, newconfig): + config = newconfig([], """ + [testenv:devenv] + envdir = devenv + """) + envconfig = config.envconfigs['devenv'] + assert envconfig.envdir == tmpdir.join('devenv') + + def test_envdir_set_manually_with_substitutions(self, tmpdir, newconfig): + config = newconfig([], """ + [testenv:devenv] + envdir = {toxworkdir}/foobar + """) + envconfig = config.envconfigs['devenv'] + assert envconfig.envdir == config.toxworkdir.join('foobar') + + def test_package_flag(self, tmpdir, newconfig): + config = newconfig([], """ + [testenv:py27] + """) + envconfig = config.envconfigs['py27'] + assert envconfig.package == True + + config = newconfig([], """ + [testenv:py27] + package = False + """) + envconfig = config.envconfigs['py27'] + assert envconfig.package == False + class TestConfigPackage: def test_defaults(self, tmpdir, newconfig): config = newconfig([], "") |
