2010-10-14 01:30:00 +08:00
|
|
|
|
2010-10-14 07:25:09 +08:00
|
|
|
.. _`good practises`:
|
|
|
|
|
2010-10-14 01:30:00 +08:00
|
|
|
Good Practises
|
|
|
|
=================================================
|
|
|
|
|
|
|
|
Recommendation: install tool and dependencies virtually
|
|
|
|
-----------------------------------------------------------
|
|
|
|
|
|
|
|
We recommend to work with virtual environments
|
|
|
|
(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
|
|
|
|
|
|
|
|
.. _standalone:
|
|
|
|
|
2010-10-14 07:25:09 +08:00
|
|
|
|
|
|
|
Choosing a test layout
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
py.test supports common test layouts.
|
|
|
|
|
|
|
|
XXX
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-14 01:30:00 +08:00
|
|
|
Generating a py.test standalone Script
|
|
|
|
-------------------------------------------
|
|
|
|
|
|
|
|
If you are a maintainer or application developer and want users
|
|
|
|
to run tests you can use a facility to generate a standalone
|
|
|
|
"py.test" script that you can tell users to run::
|
|
|
|
|
|
|
|
py.test --genscript=mytest
|
|
|
|
|
|
|
|
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::
|
|
|
|
|
|
|
|
python mytest --pastebin=all
|
|
|
|
|
|
|
|
and ask them to send you the resulting URL. The resulting script has
|
|
|
|
all core features and runs unchanged under Python2 and Python3 interpreters.
|
|
|
|
|
|
|
|
.. _`Distribute for installation`: http://pypi.python.org/pypi/distribute#installation-instructions
|
|
|
|
.. _`distribute installation`: http://pypi.python.org/pypi/distribute
|
|
|
|
|
|
|
|
.. include:: links.inc
|