@@ -960,16 +960,27 @@ def __call__(self, function):
960960def fixture (scope = "function" , params = None , autouse = False , ids = None , name = None ):
961961 """Decorator to mark a fixture factory function.
962962
963- This decorator can be used (with or without parameters) to define a
964- fixture function. The name of the fixture function can later be
965- referenced to cause its invocation ahead of running tests: test
966- modules or classes can use the pytest.mark.usefixtures(fixturename)
967- marker. Test functions can directly use fixture names as input
963+ This decorator can be used, with or without parameters, to define a
964+ fixture function.
965+
966+ The name of the fixture function can later be referenced to cause its
967+ invocation ahead of running tests: test
968+ modules or classes can use the ``pytest.mark.usefixtures(fixturename)``
969+ marker.
970+
971+ Test functions can directly use fixture names as input
968972 arguments in which case the fixture instance returned from the fixture
969973 function will be injected.
970974
975+ Fixtures can provide their values to test functions using ``return`` or ``yield``
976+ statements. When using ``yield`` the code block after the ``yield`` statement is executed
977+ as teardown code regardless of the test outcome, and must yield exactly once.
978+
971979 :arg scope: the scope for which this fixture is shared, one of
972- "function" (default), "class", "module" or "session".
980+ ``"function"`` (default), ``"class"``, ``"module"``,
981+ ``"package"`` or ``"session"``.
982+
983+ ``"package"`` is considered **experimental** at this time.
973984
974985 :arg params: an optional list of parameters which will cause multiple
975986 invocations of the fixture function and all of the tests
@@ -990,10 +1001,6 @@ def fixture(scope="function", params=None, autouse=False, ids=None, name=None):
9901001 to resolve this is to name the decorated function
9911002 ``fixture_<fixturename>`` and then use
9921003 ``@pytest.fixture(name='<fixturename>')``.
993-
994- Fixtures can optionally provide their values to test functions using a ``yield`` statement,
995- instead of ``return``. In this case, the code block after the ``yield`` statement is executed
996- as teardown code regardless of the test outcome. A fixture function must yield exactly once.
9971004 """
9981005 if callable (scope ) and params is None and autouse is False :
9991006 # direct decoration
0 commit comments