2009-03-22 08:38:43 +08:00
|
|
|
.. _`setuptools installation`: http://pypi.python.org/pypi/setuptools
|
|
|
|
|
|
|
|
|
2009-04-02 15:10:16 +08:00
|
|
|
==================
|
|
|
|
Quickstart
|
|
|
|
==================
|
2009-03-22 08:38:43 +08:00
|
|
|
|
2009-11-02 20:00:48 +08:00
|
|
|
.. _here: ../install.html
|
2009-03-22 08:38:43 +08:00
|
|
|
|
2009-11-06 00:46:14 +08:00
|
|
|
If you have the ``easy_install`` tool (otherwise see here_) just type::
|
2009-03-22 08:38:43 +08:00
|
|
|
|
2009-07-21 00:54:08 +08:00
|
|
|
easy_install -U py
|
2009-03-22 08:38:43 +08:00
|
|
|
|
2009-08-19 01:04:57 +08:00
|
|
|
Now create a file ``test_sample.py`` with the following content:
|
|
|
|
|
|
|
|
.. sourcecode:: python
|
2009-03-22 08:38:43 +08:00
|
|
|
|
|
|
|
# content of test_sample.py
|
2009-08-19 01:04:57 +08:00
|
|
|
def func(x):
|
|
|
|
return x + 1
|
2009-03-22 08:38:43 +08:00
|
|
|
def test_answer():
|
2009-09-24 01:43:43 +08:00
|
|
|
assert func(3) == 5
|
2009-03-22 08:38:43 +08:00
|
|
|
|
2009-07-21 00:54:08 +08:00
|
|
|
You can now run the test file like this::
|
2009-03-22 08:38:43 +08:00
|
|
|
|
2009-08-19 01:04:57 +08:00
|
|
|
py.test test_sample.py
|
|
|
|
|
|
|
|
and will see output like this:
|
|
|
|
|
|
|
|
.. sourcecode:: python
|
|
|
|
|
|
|
|
=========================== test session starts ============================
|
2009-11-06 00:46:14 +08:00
|
|
|
python: platform linux2 -- Python 2.6.2 -- pytest-1.1.0
|
2009-08-19 01:04:57 +08:00
|
|
|
test object 1: test_sample.py
|
|
|
|
|
|
|
|
test_sample.py F
|
|
|
|
|
|
|
|
================================= FAILURES =================================
|
|
|
|
_______________________________ test_answer ________________________________
|
|
|
|
|
|
|
|
def test_answer():
|
|
|
|
> assert func(3) == 5
|
|
|
|
E assert 4 == 5
|
|
|
|
E + where 4 = func(3)
|
|
|
|
|
|
|
|
test_sample.py:6: AssertionError
|
|
|
|
========================= 1 failed in 0.08 seconds =========================
|
|
|
|
|
|
|
|
This output contains Python interpreter information, a list of test objects,
|
|
|
|
a progress report and important details of the failure.
|
|
|
|
|
|
|
|
**Where to go from here**
|
|
|
|
|
|
|
|
`features`_: overview and description of test features
|
2009-03-22 08:38:43 +08:00
|
|
|
|
2009-11-06 00:46:14 +08:00
|
|
|
`plugins`_: a list of available plugins which each contain usage examples
|
|
|
|
|
|
|
|
`tutorials`_: some blog entries and starting points with code examples
|
|
|
|
|
|
|
|
`contact`_: if you want to feedback or have problems
|
2009-03-22 08:38:43 +08:00
|
|
|
|
2009-08-19 01:04:57 +08:00
|
|
|
.. _`contact`: ../contact.html
|
2009-07-21 00:54:08 +08:00
|
|
|
.. _`automatically collected`: features.html#autocollect
|
2009-11-02 20:00:48 +08:00
|
|
|
.. _install: ../install.html
|
2009-11-06 00:46:14 +08:00
|
|
|
.. _plugins: plugin/index.html
|
2009-04-13 21:58:26 +08:00
|
|
|
.. _features: features.html
|
2009-07-04 22:14:14 +08:00
|
|
|
.. _tutorials: talks.html
|
|
|
|
|
2009-03-22 08:38:43 +08:00
|
|
|
|
|
|
|
|