summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2012-07-18 20:17:33 +0200
committerholger krekel <holger@merlinux.eu>2012-07-18 20:17:33 +0200
commit3a69d68a851fcac8655202fb5672280f2a9bab1e (patch)
treebc80fc93dc5f575a4ae16cede55bfc0b15268f90
parentc4108522f838fe458023fc432343dc156e22d975 (diff)
downloadtox-3a69d68a851fcac8655202fb5672280f2a9bab1e.tar.gz
make
python setup.py test run tests via tox itself.
-rwxr-xr-xCHANGELOG6
-rw-r--r--doc/conf.py2
-rw-r--r--doc/config-v1.txt196
-rw-r--r--doc/example/basic.txt34
-rw-r--r--doc/index.txt1
-rw-r--r--setup.py16
-rw-r--r--tox.ini5
7 files changed, 60 insertions, 200 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 72b8bfe..45d143e 100755
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+1.4.DEV
+-----------------
+
+- "python setup.py test" now runs tox tests via tox :)
+ also added an example on how to do it for your project.
+
1.4.1
-----------------
diff --git a/doc/conf.py b/doc/conf.py
index 0bd51f3..ac558b4 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -48,7 +48,7 @@ copyright = u'2011, holger krekel and others'
# built documents.
#
# The short X.Y version.
-release = version = "1.4-1"
+release = version = "1.4-3"
# The full version, including alpha/beta/rc tags.
# The language for content autogenerated by Sphinx. Refer to documentation
diff --git a/doc/config-v1.txt b/doc/config-v1.txt
deleted file mode 100644
index fb598ad..0000000
--- a/doc/config-v1.txt
+++ /dev/null
@@ -1,196 +0,0 @@
-
-V1 draft: multi-dimensional configuration with tox
--------------------------------------------------------
-
-Problems:
-
-- there is no way to define dependency or other variants in tox.ini files,
- instead you have explicitely spell out all combinations in
- separate testenvs. Examples:
-
- http://code.larlet.fr/django-rest-framework/src/eed0f39a7e45/tox.ini
- https://bitbucket.org/tabo/django-treebeard/src/93b579395a9c/tox.ini
-
-- tox always uses pip currently. So there is no check for your packages
- that installing with easy_install will work. Moreover, some packages,
- like greenlet on Win32, require easy_install if you have no suitable
- C-compiler on the machine. Tox cannot be used then currently.
-
-Goals:
-
-- allow to more easily define and run dependency/interpreter variants
- with testenvs
-- allow to run variants of installing via easy_install or pip.
-
-
-Generating and selecting variants
-----------------------------------------------
-
-Suppose you want to test your package against mypkg-1.3 and mypkg-1.4
-framework versions and against python2.6,2.7,pypy-1.9 and 3.2 interpreters.
-Today you would have to create 2*4 = 8 ``[testenv*]`` sections to instruct
-tox to test against all of them. With tox-1.X you can use a new mechanism
-which is based on two ideas:
-
-* allow to specify partial testenv values in [testenv-VARIANT] sections
-* introduce "generator" expressions to the "envlist" setting to ease
- enumerating all variant combinations.
-
-Without much further introduction, here is an example ``tox.ini``::
-
- envlist =
- py[26,27,32,py]-mypkg[13,14]
-
- [testenv]
- deps = nose
- commands = nosetests
-
- [testenv-mypkg13]
- +deps = mypkg<1.4
-
- [testenv-django14]
- +deps = mypkg<1.5
-
-If you don't want to run django-mypkg with pypy the envlist would look like
-this::
-
- envlist =
- py[26,27,32]-mypkg[13,14]
- pypy-mypkg14
-
-
-Generator expressions in the envlist setting
-----------------------------------------------------------
-
-Generator expressions in the ``envlist`` work like this:
-
-* ``[...]`` parts contain a comma-separated list of names. Each name
- will generate a new environment reference.
-* repeat the process until there are no more generator expressions
-
-Variant specification with [testenv-VARNAME]
-----------------------------------------------
-
-The ``[testenv-mypkg13]`` and ``[testenv-mypkg14]`` can define
-settings for the respective variant. Their specification
-can use a new ``+deps`` setting to allow for appending dependencies rather than replacing it.
-
-Showing all expanded sections
--------------------------------
-
-To help with understanding how the variants will produce section values,
-you can ask tox to show their expansion with a new option:
-
- $ tox -l
- [XXX output ommitted for now]
-
-
-Making sure your packages installs with easy_install
-------------------------------------------------------
-
-The new "installer" testenv setting allows to specify the tool for installation:
-
- [testenv]
- installer = easy_install
-
-If you want to have your package installed with both easy_install
-and pip, you can use variants again:
-
- [testenv-easy]
- installer = easy_install
-
- [testenv-pip]
- installer = pip
-
- [tox]
- envlist = py[26,27,32]-django[13,14]-[easy,pip]
-
-Note that tox comes with some predefined variants, namely:
-
- - [easy,pip] use easy_install or pip
- - [py24,py25,py26,py27,py31,py32,pypy,jy] use the respective pythonNN
- or PyPy or Jython interpreter
-
-You can use those in your "envlist" specification without the need to
-define them yourself.
-
-Transforming the examples: django-rest
-------------------------------------------------
-
-The original `tox.ini <http://code.larlet.fr/django-rest-framework/src/eed0f39a7e45/tox.ini>`_ file has 159 lines and a lot of repetition, the new one would
-have 26 lines and almost no repetition::
-
- [tox]
- envlist = py[25,26,27]-django[12,13][,-example]
-
- [testenv]
- commands = python setup.py test
-
- deps=
- coverage==3.4
- unittest-xml-reporting==1.2
- Pyyaml==3.10
-
- [testenv-django12]
- +deps= django==1.2.4
-
- [testenv-django12]
- +deps= django==1.2.4
-
- [testenv-example]
- deps =
- wsgiref==0.1.2
- Pygments==1.4
- httplib2==0.6.0
- Markdown==2.0.3
-
- commands = python examples/runtests.py
-
-Apart from the much more concise specification, it is now also easy to add further variants like testing installation with easy_install in addition
-to pip.
-
-Transforming the examples: django-treebeard
-------------------------------------------------
-
-Another `tox.ini <https://bitbucket.org/tabo/django-treebeard/raw/93b579395a9c/tox.ini>`_ has 233 lines and runs tests against multiple Postgres and Mysql engines in the same testenv section. We can easily split this and reduce to 39 non-repetive lines::
-
- [tox]
- envlist =
- py[24,25,26,27]-django[11,12,13]-[nodb,pg,mysql]
- docs
-
- [testenv:docs]
- changedir = docs
- deps =
- Sphinx
- Django
- commands =
- make clean
- make html
-
- [testenv]
- deps=
- coverage
- MySQL-python
- psycopg2
- pysqlite
-
- [testenv-nodb]
- +deps=pysqlite
- commands =
- {envpython} runtests.py {posargs}
-
- [testenv-pg]
- +deps = psycopg2
- commands =
- {envpython} runtests.py --DATABASE_ENGINE=postgresql_psycopg2 --DATABASE_USER=postgres {posargs}
-
- [testenv-mysql]
- +deps = MySQL-python
- commands =
- {envpython} runtests.py --DATABASE_ENGINE=mysql --DATABASE_USER=root {posargs}
-
- [testenv-django10]
- +deps = Django==1.0.4
-
-
diff --git a/doc/example/basic.txt b/doc/example/basic.txt
index 7e93604..3276ab1 100644
--- a/doc/example/basic.txt
+++ b/doc/example/basic.txt
@@ -120,3 +120,37 @@ 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.
+
+Integration with setuptools/distribute test commands
+----------------------------------------------------
+
+Distribute/Setuptools support test requirements
+and you can extend its test command to trigger
+a test run when ``python setup.py test`` is issued::
+
+ from setuptools.command.test import test as TestCommand
+ import sys
+
+ class Tox(TestCommand):
+ def finalize_options(self):
+ TestCommand.finalize_options(self)
+ self.test_args = []
+ self.test_suite = True
+ def run_tests(self):
+ #import here, cause outside the eggs aren't loaded
+ import tox
+ errno = tox.cmdline(self.test_args)
+ sys.exit(errno)
+
+ setup(
+ #...,
+ tests_require=['tox'],
+ cmdclass = {'test': Tox},
+ )
+
+Now if you run::
+
+ python setup.py test
+
+this will install tox and then run tox.
+
diff --git a/doc/index.txt b/doc/index.txt
index 2a4203c..f8ecf34 100644
--- a/doc/index.txt
+++ b/doc/index.txt
@@ -93,6 +93,7 @@ Current features
install
examples
config
+ config-v1
support
changelog
links
diff --git a/setup.py b/setup.py
index af74856..4d7da17 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,6 @@
import sys
from setuptools import setup
+from setuptools.command.test import test as TestCommand
long_description="""
What is Tox?
@@ -25,6 +26,15 @@ For more information, docs and many examples please checkout the `home page`_:
.. _`home page`: http://tox.testrun.org/
"""
+class Tox(TestCommand):
+ def finalize_options(self):
+ TestCommand.finalize_options(self)
+ self.test_args = []
+ self.test_suite = True
+ def run_tests(self):
+ #import here, cause outside the eggs aren't loaded
+ import tox
+ tox.cmdline(self.test_args)
def main():
version = sys.version_info[:2]
@@ -43,6 +53,10 @@ def main():
author_email='holger@merlinux.eu',
packages=['tox', ],
entry_points={'console_scripts': 'tox=tox:cmdline'},
+ # we use a public tox version to test, see tox.ini's testenv
+ # "deps" definition for the required dependencies
+ tests_require=['tox'],
+ cmdclass={"test": Tox},
install_requires=install_requires,
zip_safe=True,
classifiers=[
@@ -60,4 +74,4 @@ def main():
)
if __name__ == '__main__':
- main() \ No newline at end of file
+ main()
diff --git a/tox.ini b/tox.ini
index ce26bae..42d93c8 100644
--- a/tox.ini
+++ b/tox.ini
@@ -9,7 +9,8 @@ commands=echo {posargs}
[testenv]
commands=py.test --junitxml={envlogdir}/junit-{envname}.xml {posargs}
-deps=:testrun:pytest :testrun:py
+deps=pytest
+ py
[testenv:docs]
basepython=python
@@ -19,7 +20,7 @@ deps=:pypi:sphinx
commands=
py.test -v \
--junitxml={envlogdir}/junit-{envname}.xml \
- check_sphinx.py []
+ check_sphinx.py {posargs}
[pytest]
rsyncdirs=tests tox