Skip to content

Commit 0ca0696

Browse files
committed
Improve docs
1 parent 2ffe354 commit 0ca0696

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

_pytest/fixtures.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,9 @@ 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+
"""
10771080
fixture_def = FixtureDef(self, nodeid, name, obj,
10781081
scope, marker.params,
10791082
unittest=unittest, ids=marker.ids)
@@ -1101,6 +1104,13 @@ def new_fixture_def(name, scope):
11011104
self._nodeid_and_autousenames.append((nodeid or '', autousenames))
11021105

11031106
def getfixturedefs(self, argname, nodeid):
1107+
"""
1108+
Gets a list of fixtures which are applicable to the given node id.
1109+
1110+
:param str argname: name of the fixture to search for
1111+
:param str nodeid: full node id of the requesting test.
1112+
:return: list[FixtureDef]
1113+
"""
11041114
try:
11051115
fixturedefs = self._arg2fixturedefs[argname]
11061116
except KeyError:
@@ -1114,6 +1124,15 @@ def _matchfactories(self, fixturedefs, nodeid):
11141124
yield fixturedef
11151125

11161126
def getfixturedefs_multiple_scopes(self, argname, nodeid):
1127+
"""
1128+
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
1130+
the form: "<argname>:<scope>" (for example "tmpdir:session").
1131+
1132+
:return: dict of "argname" -> [FixtureDef].
1133+
1134+
Arguments similar to ``getfixturedefs``.
1135+
"""
11171136
prefix = argname + ':'
11181137
fixturedefs_by_argname = dict((k, v) for k, v in self._arg2fixturedefs.items()
11191138
if k.startswith(prefix))

testing/python/invocation_scope.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_acceptance(self, testdir):
1212
Some notes:
1313
1414
- For each scope, define 2 fixtures of the same scope which use the "stack" fixture,
15-
to ensure they get the same "stack" instance for its scope.
15+
to ensure they get the same "stack" instance for that scope.
1616
- Creates multiple test files, which tests on each modifying and checking fixtures to
1717
ensure things are working properly.
1818
"""

0 commit comments

Comments
 (0)