From 47d8c12f61b6724aedc2b76cb8c9742380219cb1 Mon Sep 17 00:00:00 2001 From: Cunliang Geng Date: Wed, 28 Feb 2024 13:57:20 +0100 Subject: [PATCH] Update conftest.py --- tests/conftest.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 7bb93bbf..974265ea 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,9 +1,18 @@ import os import tempfile +import zipfile from . import DATA_DIR -# Specify the config file via environment variable before importing nplinker in any test. -os.environ["NPLINKER_CONFIG_FILE"] = str(DATA_DIR / "nplinker_demo1.toml") +# Prepare dataset for local mode testing +# ⚠️ Multiple temp dirs will be created if using parallel testing. +temp_dir = tempfile.mkdtemp(prefix="nplinker_") +nplinker_root_dir = os.path.join(temp_dir, "local_mode_example") +with zipfile.ZipFile(DATA_DIR / "local_mode_example.zip", "r") as zip_ref: + zip_ref.extractall(temp_dir) + # NPLinker setting `root_dir` must be a path that exists, so setting it to a temporary directory. -os.environ["NPLINKER_ROOT_DIR"] = tempfile.mkdtemp(prefix="nplinker_") +os.environ["NPLINKER_ROOT_DIR"] = nplinker_root_dir + +# Specify the config file via environment variable before importing nplinker in any test. +os.environ["NPLINKER_CONFIG_FILE"] = str(DATA_DIR / "nplinker_local_mode.toml")