def _temp_dir(self, tmp_path_factory: pytest.TempPathFactory) -> Iterator[None]:
        """Create a temp dir for the tests, if they want it."""
        if self.run_in_temp_dir:
            tmpdir = tmp_path_factory.mktemp("t")
            self.temp_dir = str(tmpdir)
            with change_dir(self.temp_dir):
                # Modules should be importable from this temp directory.  We don't
                # use '' because we make lots of different temp directories and
                # nose's caching importer can get confused.  The full path prevents
                # problems.
                sys.path.insert(0, os.getcwd())
                yield
        else:
            yield
Create a temp dir for the tests, if they want it.
tests/mixins.py