def test_resolvesource_local_dir(mocker: MockerFixture, tmpdir: py.path.local) -> None: """Test ResolveSource context manager when input is a local directory.""" mocked_handledownload = mocker.patch( "paranoid_openvpn.input_handlers.HandleDownload") mocked_handlezip = mocker.patch( "paranoid_openvpn.input_handlers.HandleZip") tmpdir = Path(tmpdir) with ResolveSource(tmpdir) as resolved_src: assert resolved_src == Path(tmpdir) assert not mocked_handledownload.called assert not mocked_handlezip.called assert tmpdir.exists()
def _collectfile(self, path: py.path.local, handle_dupes: bool = True) -> Sequence[nodes.Collector]: assert (path.isfile( )), "{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})".format( path, path.isdir(), path.exists(), path.islink()) ihook = self.gethookproxy(path) if not self.isinitpath(path): if ihook.pytest_ignore_collect(path=path, config=self.config): return () if handle_dupes: keepduplicates = self.config.getoption("keepduplicates") if not keepduplicates: duplicate_paths = self.config.pluginmanager._duplicatepaths if path in duplicate_paths: return () else: duplicate_paths.add(path) return ihook.pytest_collect_file( path=path, parent=self) # type: ignore[no-any-return]