Skip to content

Commit

Permalink
autouse fork/spawn fixture so we test both
Browse files Browse the repository at this point in the history
this is necessary for getting compatibility with windows and macos
  • Loading branch information
pattonw committed Nov 19, 2024
1 parent 18a0b20 commit ea9f5dd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
3 changes: 0 additions & 3 deletions tests/conf.py

This file was deleted.

28 changes: 28 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ea9f5dd

Please sign in to comment.