Return the module collection node for ``source``. Writes ``source`` to a file using :py:meth:`makepyfile` and then runs the pytest collection on it, returning the collection node for the test module. :param source: The source code of the module to collec
(
self,
source: Union[str, "os.PathLike[str]"],
configargs=(),
*,
withinit: bool = False,
)
| 1254 | return self.genitems([modcol]) |
| 1255 | |
| 1256 | def getmodulecol( |
| 1257 | self, |
| 1258 | source: Union[str, "os.PathLike[str]"], |
| 1259 | configargs=(), |
| 1260 | *, |
| 1261 | withinit: bool = False, |
| 1262 | ): |
| 1263 | """Return the module collection node for ``source``. |
| 1264 | |
| 1265 | Writes ``source`` to a file using :py:meth:`makepyfile` and then |
| 1266 | runs the pytest collection on it, returning the collection node for the |
| 1267 | test module. |
| 1268 | |
| 1269 | :param source: |
| 1270 | The source code of the module to collect. |
| 1271 | |
| 1272 | :param configargs: |
| 1273 | Any extra arguments to pass to :py:meth:`parseconfigure`. |
| 1274 | |
| 1275 | :param withinit: |
| 1276 | Whether to also write an ``__init__.py`` file to the same |
| 1277 | directory to ensure it is a package. |
| 1278 | """ |
| 1279 | if isinstance(source, os.PathLike): |
| 1280 | path = self.path.joinpath(source) |
| 1281 | assert not withinit, "not supported for paths" |
| 1282 | else: |
| 1283 | kw = {self._name: str(source)} |
| 1284 | path = self.makepyfile(**kw) |
| 1285 | if withinit: |
| 1286 | self.makepyfile(__init__="#") |
| 1287 | self.config = config = self.parseconfigure(path, *configargs) |
| 1288 | return self.getnode(config, path) |
| 1289 | |
| 1290 | def collect_by_name( |
| 1291 | self, modcol: Collector, name: str |
no test coverage detected