aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/conftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/tests/conftest.py')
-rw-r--r--packages/meshbay-node/tests/conftest.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/conftest.py b/packages/meshbay-node/tests/conftest.py
index 9ef23a3..32c9b3d 100644
--- a/packages/meshbay-node/tests/conftest.py
+++ b/packages/meshbay-node/tests/conftest.py
@@ -18,6 +18,48 @@ needs_subprocess = pytest.mark.skipif(
)
@pytest.fixture(autouse=True)
+def _no_log_file_in_the_developers_profile(monkeypatch):
+ """A test that runs the daemon's entry point must not open its log file.
+
+ On Windows that file is %LOCALAPPDATA%\\meshbay\\state\\node.log -- the
+ developer's own node's log. The first run of the suite with it appended
+ every later test's log lines there, through a handler left on the root
+ logger. A test about the log file points log_file() somewhere of its own.
+ """
+ import logging
+
+ from meshbay_node import platform as _plat
+ monkeypatch.setattr(_plat, "log_file", lambda: None)
+ root = logging.getLogger()
+ before = list(root.handlers)
+ yield
+ for h in root.handlers[:]:
+ if h not in before and getattr(h, "baseFilename", None):
+ root.removeHandler(h)
+ h.close()
+
+
+@pytest.fixture(scope="session")
+def _throwaway_profile(tmp_path_factory):
+ return tmp_path_factory.mktemp("profile")
+
+
+@pytest.fixture(autouse=True)
+def _no_test_touches_the_developers_profile(monkeypatch, _throwaway_profile):
+ """Every per-user location, pointed somewhere nobody lives.
+
+ Tests redirected HOME and nothing else, which isolates nothing on Windows:
+ Path.home() reads USERPROFILE there and the node's own directories come from
+ LOCALAPPDATA. `member invite` and `operator pair`, walked by the CLI tests,
+ wrote their codes into the developer's real node directory and a
+ ~/.local/share/meshbay nobody had, on every run. A test that sets its own
+ HOME still can; it just no longer falls through to the real one.
+ """
+ for var in ("HOME", "USERPROFILE", "LOCALAPPDATA", "APPDATA"):
+ monkeypatch.setenv(var, str(_throwaway_profile / var.lower()))
+
+
+@pytest.fixture(autouse=True)
def _restore_media_tool_paths():
"""Put `platform`'s resolved ffmpeg/ffprobe paths back after every test.