2009-04-02 15:10:16 +08:00
|
|
|
|
2010-10-11 05:45:45 +08:00
|
|
|
installing py.test
|
2008-08-16 23:26:59 +08:00
|
|
|
===================================================
|
|
|
|
|
2010-10-11 05:45:45 +08:00
|
|
|
**PyPI name**: pytest_
|
2009-12-24 02:58:52 +08:00
|
|
|
|
2010-10-11 05:45:45 +08:00
|
|
|
**hg repository**: https://bitbucket.org/hpk42/pytest
|
2009-11-06 00:46:14 +08:00
|
|
|
|
2010-10-11 05:45:45 +08:00
|
|
|
**Compatibility**: Python 2.4-3.2, Jython, PyPy on Unix/Posix and Windows
|
2009-11-06 00:46:14 +08:00
|
|
|
|
|
|
|
.. _`easy_install`:
|
|
|
|
|
2010-09-14 21:43:00 +08:00
|
|
|
Installation using easy_install
|
2010-10-11 05:45:45 +08:00
|
|
|
----------------------------------------
|
2009-06-30 18:42:57 +08:00
|
|
|
|
2010-10-11 05:45:45 +08:00
|
|
|
You need setuptools_ or Distribute_ to be able to simply type::
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2010-10-11 05:45:45 +08:00
|
|
|
easy_install -U pytest
|
|
|
|
|
|
|
|
to install the latest release of ``py.test``. The ``-U`` switch
|
|
|
|
triggers an upgrade if you already have an older version installed.
|
2010-09-14 21:43:00 +08:00
|
|
|
Note that setuptools works ok with Python2 interpreters while `Distribute`_
|
|
|
|
additionally works with Python3 and also avoid some issues on Windows.
|
2009-11-02 20:00:48 +08:00
|
|
|
|
2010-09-14 21:43:00 +08:00
|
|
|
Known issues:
|
2009-11-06 00:46:14 +08:00
|
|
|
|
2010-09-14 21:43:00 +08:00
|
|
|
- **Windows**: If "easy_install" or "py.test" are not found
|
|
|
|
please see here for preparing your environment for running
|
|
|
|
command line tools: `Python for Windows`_. You may alternatively
|
|
|
|
use an `ActivePython install`_ which makes command line tools
|
|
|
|
automatically available under Windows.
|
|
|
|
|
|
|
|
.. _`ActivePython install`: http://www.activestate.com/activepython/downloads
|
|
|
|
|
|
|
|
.. _`Jython does not create command line launchers`: http://bugs.jython.org/issue1491
|
|
|
|
|
|
|
|
- **Jython2.5.1 on Windows XP**: `Jython does not create command line launchers`_
|
|
|
|
so ``py.test`` will not work correctly. You may install py.test on
|
|
|
|
CPython and type ``py.test --genscript=mytest`` and then use
|
|
|
|
``jython mytest`` to run py.test for your tests to run in Jython.
|
|
|
|
|
|
|
|
- **On Linux**: If ``easy_install`` fails because it needs to run
|
|
|
|
as the superuser you are trying to install things globally
|
|
|
|
and need to put ``sudo`` in front of the command.
|
2009-11-06 00:46:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
.. _quickstart: test/quickstart.html
|
|
|
|
|
2010-09-14 21:43:00 +08:00
|
|
|
|
|
|
|
Recommendation: install tool and dependencies virtually
|
2010-10-11 05:45:45 +08:00
|
|
|
-----------------------------------------------------------
|
2010-09-14 21:43:00 +08:00
|
|
|
|
2010-10-11 05:45:45 +08:00
|
|
|
I recommend to work with virtual environments
|
2010-09-14 21:43:00 +08:00
|
|
|
(e.g. virtualenv_ or buildout_ based) and use easy_install_
|
|
|
|
(or pip_) for installing py.test/pylib and any dependencies
|
|
|
|
you need to run your tests. Local virtual Python environments
|
|
|
|
(as opposed to system-wide "global" environments) make for a more
|
|
|
|
reproducible and reliable test environment.
|
|
|
|
|
|
|
|
.. _`virtualenv`: http://pypi.python.org/pypi/virtualenv
|
|
|
|
.. _`buildout`: http://www.buildout.org/
|
|
|
|
.. _pip: http://pypi.python.org/pypi/pip
|
|
|
|
|
2010-01-03 21:19:31 +08:00
|
|
|
.. _standalone:
|
|
|
|
|
|
|
|
Generating a py.test standalone Script
|
2010-10-11 05:45:45 +08:00
|
|
|
-------------------------------------------
|
2010-01-03 21:19:31 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
If you are a maintainer or application developer and want users
|
2010-01-03 21:19:31 +08:00
|
|
|
to run tests you can use a facility to generate a standalone
|
|
|
|
"py.test" script that you can tell users to run::
|
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
py.test --genscript=mytest
|
2010-01-03 21:19:31 +08:00
|
|
|
|
|
|
|
will generate a ``mytest`` script that is, in fact, a ``py.test`` under
|
|
|
|
disguise. You can tell people to download and then e.g. run it like this::
|
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
python mytest --pastebin=all
|
2010-01-03 21:19:31 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
and ask them to send you the resulting URL. The resulting script has
|
|
|
|
all core features and runs unchanged under Python2 and Python3 interpreters.
|
2010-01-03 21:19:31 +08:00
|
|
|
|
2010-09-14 21:43:00 +08:00
|
|
|
.. _`Python for Windows`: http://www.imladris.com/Scripts/PythonForWindows.html
|
2009-06-30 18:42:57 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
.. _`Distribute`:
|
2009-11-02 20:00:48 +08:00
|
|
|
.. _`Distribute for installation`: http://pypi.python.org/pypi/distribute#installation-instructions
|
2009-09-07 23:53:50 +08:00
|
|
|
.. _`distribute installation`: http://pypi.python.org/pypi/distribute
|
2008-08-22 21:41:17 +08:00
|
|
|
|