71 lines
1.8 KiB
Plaintext
71 lines
1.8 KiB
Plaintext
.. _`setuptools installation`: http://pypi.python.org/pypi/setuptools
|
|
|
|
|
|
==================
|
|
Quickstart
|
|
==================
|
|
|
|
.. _here: ../install.html
|
|
|
|
If you have the ``easy_install`` tool (otherwise see here_) just type::
|
|
|
|
easy_install -U py
|
|
|
|
Now create a file ``test_sample.py`` with the following content:
|
|
|
|
.. sourcecode:: python
|
|
|
|
# content of test_sample.py
|
|
def func(x):
|
|
return x + 1
|
|
def test_answer():
|
|
assert func(3) == 5
|
|
|
|
You can now run the test file like this::
|
|
|
|
py.test test_sample.py
|
|
|
|
and will see output like this:
|
|
|
|
.. sourcecode:: python
|
|
|
|
=========================== test session starts ============================
|
|
python: platform linux2 -- Python 2.6.2 -- pytest-1.1.0
|
|
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
|
|
|
|
`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
|
|
|
|
.. _`contact`: ../contact.html
|
|
.. _`automatically collected`: features.html#autocollect
|
|
.. _install: ../install.html
|
|
.. _plugins: plugin/index.html
|
|
.. _features: features.html
|
|
.. _tutorials: talks.html
|
|
|
|
|
|
|