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

Method spawn_pytest

src/_pytest/pytester.py:1474–1488  ·  view source on GitHub ↗

Run pytest using pexpect. This makes sure to use the right pytest and sets up the temporary directory locations. The pexpect child is returned.

(
        self, string: str, expect_timeout: float = 10.0
    )

Source from the content-addressed store, hash-verified

1472 return self.run(*args, timeout=timeout)
1473
1474 def spawn_pytest(
1475 self, string: str, expect_timeout: float = 10.0
1476 ) -> "pexpect.spawn":
1477 """Run pytest using pexpect.
1478
1479 This makes sure to use the right pytest and sets up the temporary
1480 directory locations.
1481
1482 The pexpect child is returned.
1483 """
1484 basetemp = self.path / "temp-pexpect"
1485 basetemp.mkdir(mode=0o700)
1486 invoke = " ".join(map(str, self._getpytestargs()))
1487 cmd = f"{invoke} --basetemp={basetemp} {string}"
1488 return self.spawn(cmd, expect_timeout=expect_timeout)
1489
1490 def spawn(self, cmd: str, expect_timeout: float = 10.0) -> "pexpect.spawn":
1491 """Run a command using pexpect.

Calls 3

_getpytestargsMethod · 0.95
spawnMethod · 0.95
mkdirMethod · 0.45

Tested by

no test coverage detected