Skip to content

Commit f0d7a39

Browse files
committed
Added fixture to create a tmp_path Path that will persist for the test session
1 parent 43b9bfd commit f0d7a39

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tests/conftest.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
from tests import murfey_db_engine, murfey_db_url
1515

1616

17+
@pytest.fixture(scope="session")
18+
def session_tmp_path(tmp_path_factory) -> Path:
19+
"""
20+
Creates a temporary path that persists for the entire test session
21+
"""
22+
return tmp_path_factory.mktemp("session_tmp")
23+
24+
1725
@pytest.fixture
1826
def start_postgres():
1927
clear(murfey_db_url)
@@ -40,8 +48,8 @@ def mock_client_configuration() -> ConfigParser:
4048

4149

4250
@pytest.fixture(scope="session")
43-
def mock_ispyb_credentials(tmp_path: Path):
44-
creds_file = tmp_path / "ispyb_creds.cfg"
51+
def mock_ispyb_credentials(session_tmp_path: Path) -> Path:
52+
creds_file = session_tmp_path / "ispyb_creds.cfg"
4553
ispyb_config = ConfigParser()
4654
# Use values from the GitHub workflow ISPyB config file
4755
ispyb_config["ispyb_sqlalchemy"] = {
@@ -58,10 +66,10 @@ def mock_ispyb_credentials(tmp_path: Path):
5866

5967
@pytest.fixture(scope="session")
6068
def mock_security_configuration(
61-
tmp_path: Path,
69+
session_tmp_path: Path,
6270
mock_ispyb_credentials: Path,
63-
):
64-
config_file = tmp_path / "security_config.yaml"
71+
) -> Path:
72+
config_file = session_tmp_path / "security_config.yaml"
6573
security_config = {
6674
"murfey_db_credentials": "/path/to/murfey_db_credentials",
6775
"crypto_key": "crypto_key",

0 commit comments

Comments
 (0)