diff --git a/tests/conf.py b/tests/conf.py deleted file mode 100644 index 57a8708d5..000000000 --- a/tests/conf.py +++ /dev/null @@ -1,3 +0,0 @@ -import multiprocessing as mp - -mp.set_start_method("fork", force=True) diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 000000000..9a90c5cab --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,28 @@ +import multiprocessing as mp +import os +import yaml + +from dacapo.options import Options + +import pytest + + +@pytest.fixture(params=["fork", "spawn"], autouse=True) +def context(monkeypatch): + ctx = mp.get_context("spawn") + monkeypatch.setattr(mp, "Queue", ctx.Queue) + monkeypatch.setattr(mp, "Process", ctx.Process) + monkeypatch.setattr(mp, "Event", ctx.Event) + monkeypatch.setattr(mp, "Value", ctx.Value) + + +@pytest.fixture(autouse=True) +def runs_base_dir(tmpdir): + options_file = tmpdir / "dacapo.yaml" + os.environ["DACAPO_OPTIONS_FILE"] = f"{options_file}" + + with open(options_file, "w") as f: + options_file.write(yaml.safe_dump({"runs_base_dir": f"{tmpdir}"})) + + assert Options.config_file() == options_file + assert Options.instance().runs_base_dir == tmpdir