MCPcopy Create free account
hub / github.com/pytest-dev/pytest / getitem

Method getitem

src/_pytest/pytester.py:1225–1245  ·  view source on GitHub ↗

Return the test item for a test function. Writes the source to a python file and runs pytest's collection on the resulting module, returning the test item for the requested function name. :param source: The module source. :param funcname:

(
        self, source: Union[str, "os.PathLike[str]"], funcname: str = "test_func"
    )

Source from the content-addressed store, hash-verified

1223 return config
1224
1225 def getitem(
1226 self, source: Union[str, "os.PathLike[str]"], funcname: str = "test_func"
1227 ) -> Item:
1228 """Return the test item for a test function.
1229
1230 Writes the source to a python file and runs pytest's collection on
1231 the resulting module, returning the test item for the requested
1232 function name.
1233
1234 :param source:
1235 The module source.
1236 :param funcname:
1237 The name of the test function for which to return a test item.
1238 """
1239 items = self.getitems(source)
1240 for item in items:
1241 if item.name == funcname:
1242 return item
1243 assert 0, "{!r} item not found in module:\n{}\nitems: {}".format(
1244 funcname, source, items
1245 )
1246
1247 def getitems(self, source: Union[str, "os.PathLike[str]"]) -> List[Item]:
1248 """Return all test items collected from the module.

Calls 2

getitemsMethod · 0.95
formatMethod · 0.45

Tested by

no test coverage detected