Skip to content

Commit 20f97c3

Browse files
committed
Small documentation improvements
1 parent 0dd1c8b commit 20f97c3

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,11 @@
116116
Example '-o xfail_strict=True'. A complete ini-options can be viewed
117117
by py.test --help. Thanks `@blueyed`_ and `@fengxx`_ for the PR
118118

119-
* New scope for fixtures: ``"invocation"``. This fixtures may be requested by fixtures from
120-
any scope, when they assume the same scope as the fixture requesting it. An ``invocation``-scoped
121-
fixture can be requested from different scopes in the same test session,
122-
in which case each scope will have its own copy. This feature is considered experimental.
119+
* Experimentally introduce new ``"invocation"`` fixture scope. At invocation scope a
120+
fixture function is cached in the same way as the fixture or test function that requests it.
121+
You can now use the builtin ``monkeypatch`` fixture from ``session``-scoped fixtures
122+
where previously you would get an error that you can not use a ``function``-scoped fixture from a
123+
``session``-scoped one.*
123124
Thanks `@nicoddemus`_ for the PR.
124125

125126
*

_pytest/fixtures.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,9 +1074,7 @@ def parsefactories(self, node_or_obj, nodeid=NOTSET, unittest=False):
10741074
assert not name.startswith(self._argprefix), name
10751075

10761076
def new_fixture_def(name, scope):
1077-
"""
1078-
Creates and registers a new FixtureDef with given name and scope.
1079-
"""
1077+
"""Create and registers a new FixtureDef with given name and scope."""
10801078
fixture_def = FixtureDef(self, nodeid, name, obj,
10811079
scope, marker.params,
10821080
unittest=unittest, ids=marker.ids)
@@ -1126,7 +1124,7 @@ def _matchfactories(self, fixturedefs, nodeid):
11261124
def getfixturedefs_multiple_scopes(self, argname, nodeid):
11271125
"""
11281126
Gets multiple scoped fixtures which are applicable to the given nodeid. Multiple scoped
1129-
fixtures are usually created by "invocation" scoped fixtures and have argnames in
1127+
fixtures are created by "invocation" scoped fixtures and have argnames in
11301128
the form: "<argname>:<scope>" (for example "tmpdir:session").
11311129
11321130
:return: dict of "argname" -> [FixtureDef].

doc/en/invocation-fixture.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ value and can manage processes which will live for the duration of the scope.
3737
3838
@pytest.fixture(scope='invocation')
3939
def process_manager():
40+
"""
41+
Return a ProcessManager instance which can be used to start
42+
long-lived processes and ensures they are terminated at the
43+
appropriate scope.
44+
"""
4045
m = ProcessManager()
4146
yield m
4247
m.shutdown_all()

0 commit comments

Comments
 (0)