diff --git a/src/psij/utils.py b/src/psij/utils.py index 47357b35..17ae2256 100644 --- a/src/psij/utils.py +++ b/src/psij/utils.py @@ -113,6 +113,7 @@ def _get_ips(self) -> List[str]: return r def _create_update_file(self) -> None: + self.work_directory.mkdir(parents=True, exist_ok=True) f = tempfile.NamedTemporaryFile(dir=self.work_directory, prefix='supd_', delete=False) name = f.name self.update_file_name = name diff --git a/tests/test_status_updater.py b/tests/test_status_updater.py new file mode 100644 index 00000000..1078238a --- /dev/null +++ b/tests/test_status_updater.py @@ -0,0 +1,16 @@ +import os +import site +import subprocess +import sys +from pathlib import Path + + +def test_a_batch_executor_starts_in_a_home_without_psij_directory(tmp_path: Path) -> None: + p = subprocess.run([sys.executable, '-c', + 'from psij import JobExecutor; JobExecutor.get_instance("slurm")'], + env={**os.environ, 'HOME': str(tmp_path), + 'PYTHONUSERBASE': site.getuserbase()}, + capture_output=True, text=True) + + assert p.returncode == 0, p.stderr + assert (tmp_path / '.psij').is_dir()