Manual docs changes so syntax is parseable
This commit is contained in:
parent
4dc5f7897d
commit
5c878001ea
|
@ -14,7 +14,7 @@ Install argcomplete using::
|
|||
|
||||
For global activation of all argcomplete enabled python applications run::
|
||||
|
||||
sudo activate-global-python-argcomplete
|
||||
sudo activate-global-python-argcomplete
|
||||
|
||||
For permanent (but not global) ``pytest`` activation, use::
|
||||
|
||||
|
|
|
@ -283,8 +283,10 @@ and then check for the ``sys._called_from_test`` flag:
|
|||
|
||||
if hasattr(sys, '_called_from_test'):
|
||||
# called from within a test run
|
||||
...
|
||||
else:
|
||||
# called "normally"
|
||||
...
|
||||
|
||||
accordingly in your application. It's also a good idea
|
||||
to use your own application module rather than ``sys``
|
||||
|
|
|
@ -250,9 +250,10 @@ instance, you can simply declare it:
|
|||
.. code-block:: python
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def smtp(...):
|
||||
def smtp():
|
||||
# the returned fixture value will be shared for
|
||||
# all tests needing it
|
||||
...
|
||||
|
||||
Finally, the ``class`` scope will invoke the fixture once per test *class*.
|
||||
|
||||
|
@ -867,6 +868,7 @@ You can specify multiple fixtures like this:
|
|||
.. code-block:: python
|
||||
|
||||
@pytest.mark.usefixtures("cleandir", "anotherfixture")
|
||||
def test(): ...
|
||||
|
||||
and you may specify fixture usage at the test module level, using
|
||||
a generic feature of the mark mechanism:
|
||||
|
|
|
@ -91,6 +91,7 @@ order doesn't even matter. You probably want to think of your marks as a set her
|
|||
if skipif:
|
||||
for condition in skipif.args:
|
||||
# eval condition
|
||||
...
|
||||
|
||||
# by this:
|
||||
for skipif in item.iter_markers('skipif'):
|
||||
|
@ -134,5 +135,5 @@ More details can be found in the `original PR <https://github.com/pytest-dev/pyt
|
|||
|
||||
.. note::
|
||||
|
||||
in a future major relase of pytest we will introduce class based markers,
|
||||
at which points markers will no longer be limited to instances of :py:class:`Mark`
|
||||
in a future major relase of pytest we will introduce class based markers,
|
||||
at which points markers will no longer be limited to instances of :py:class:`Mark`
|
||||
|
|
|
@ -366,12 +366,12 @@ test instances when using parametrize:
|
|||
|
||||
@pytest.mark.parametrize(("n", "expected"), [
|
||||
(1, 2),
|
||||
pytest.param(1, 0, marks=pytest.mark.xfail),
|
||||
pytest.param(1, 3, marks=pytest.mark.xfail(reason="some bug")),
|
||||
pytest.param(1, 0, marks=pytest.mark.xfail),
|
||||
pytest.param(1, 3, marks=pytest.mark.xfail(reason="some bug")),
|
||||
(2, 3),
|
||||
(3, 4),
|
||||
(4, 5),
|
||||
pytest.param(10, 11, marks=pytest.mark.skipif(sys.version_info >= (3, 0), reason="py2k")),
|
||||
pytest.param(10, 11, marks=pytest.mark.skipif(sys.version_info >= (3, 0), reason="py2k")),
|
||||
])
|
||||
def test_increment(n, expected):
|
||||
assert n + 1 == expected
|
||||
|
|
|
@ -150,7 +150,7 @@ it in your setuptools-invocation:
|
|||
|
||||
setup(
|
||||
name="myproject",
|
||||
packages = ['myproject']
|
||||
packages = ['myproject'],
|
||||
|
||||
# the following makes a plugin available to pytest
|
||||
entry_points = {
|
||||
|
@ -214,9 +214,9 @@ With the following typical ``setup.py`` extract:
|
|||
.. code-block:: python
|
||||
|
||||
setup(
|
||||
...
|
||||
...,
|
||||
entry_points={'pytest11': ['foo = pytest_foo.plugin']},
|
||||
...
|
||||
...,
|
||||
)
|
||||
|
||||
In this case only ``pytest_foo/plugin.py`` will be rewritten. If the
|
||||
|
@ -425,6 +425,7 @@ Let's look at a possible implementation:
|
|||
def pytest_collection_modifyitems(config, items):
|
||||
# called after collection is completed
|
||||
# you can modify the ``items`` list
|
||||
...
|
||||
|
||||
Here, ``pytest`` will pass in ``config`` (the pytest config object)
|
||||
and ``items`` (the list of collected test items) but will not pass
|
||||
|
@ -511,11 +512,13 @@ after others, i.e. the position in the ``N``-sized list of functions:
|
|||
@pytest.hookimpl(tryfirst=True)
|
||||
def pytest_collection_modifyitems(items):
|
||||
# will execute as early as possible
|
||||
...
|
||||
|
||||
# Plugin 2
|
||||
@pytest.hookimpl(trylast=True)
|
||||
def pytest_collection_modifyitems(items):
|
||||
# will execute as late as possible
|
||||
...
|
||||
|
||||
# Plugin 3
|
||||
@pytest.hookimpl(hookwrapper=True)
|
||||
|
|
Loading…
Reference in New Issue