Skip to content

Commit

Permalink
use tmp_path instead of tmp_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyleung521 committed Jan 9, 2025
1 parent fb86e43 commit e5d847e
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
import os
import glob
import tempfile
from shutil import copyfile, copy

import westpa
Expand Down Expand Up @@ -30,13 +29,13 @@ def clear_state():


@pytest.fixture
def ref_3iter(request):
def ref_3iter(request, tmp_path):
"""
Fixture that prepares a simulation directory with a completed 3-iteration WESTPA,
west.h5, plus the config file west.cfg
"""

test_dir = tempfile.mkdtemp()
test_dir = str(tmp_path)
os.chdir(test_dir)

copy_ref(test_dir)
Expand All @@ -53,12 +52,12 @@ def ref_3iter(request):


@pytest.fixture
def ref_cfg(request, tmpdir):
def ref_cfg(request, tmp_path):
"""
Fixture that prepares a simulation directory with a populated west.cfg file.
"""

test_dir = str(tmpdir)
test_dir = str(tmp_path)
os.chdir(test_dir)

copy_ref(test_dir)
Expand All @@ -77,13 +76,13 @@ def ref_cfg(request, tmpdir):


@pytest.fixture
def ref_initialized(request, tmpdir):
def ref_initialized(request, tmp_path):
"""
Fixture that prepares a simulation directory with an initialized WESTPA system,
west.h5, plus the config file west.cfg
"""

test_dir = str(tmpdir)
test_dir = str(tmp_path)

os.chdir(test_dir)
copy_ref(test_dir)
Expand All @@ -101,13 +100,13 @@ def ref_initialized(request, tmpdir):


@pytest.fixture
def ref_50iter(request, tmpdir):
def ref_50iter(request, tmp_path):
"""
Fixture that prepares a simulation directory with a completed 50-iteration WESTPA,
west.h5, plus the config file west.cfg
"""

test_dir = str(tmpdir)
test_dir = str(tmp_path)

os.chdir(test_dir)
copy_ref(test_dir)
Expand All @@ -125,13 +124,13 @@ def ref_50iter(request, tmpdir):


@pytest.fixture
def ref_multi(request, tmpdir):
def ref_multi(request, tmp_path):
"""
Fixture that prepares a simulation directory for w_multi_west, including a master
folder with sub folders 01, 02, 03 containing west_aux_ref.h5 renamed as west.h5.
"""

test_dir = str(tmpdir)
test_dir = str(tmp_path)

os.chdir(test_dir)
copy_ref(test_dir)
Expand All @@ -155,13 +154,13 @@ def ref_multi(request, tmpdir):


@pytest.fixture
def ref_multi_noaux(request, tmpdir):
def ref_multi_noaux(request, tmp_path):
"""
Fixture that prepares a simulation directory for w_multi_west, including a master
folder with sub folders 01, 02, 03 containing west_aux_ref.h5 renamed as west.h5.
"""

test_dir = str(tmpdir)
test_dir = str(tmp_path)

os.chdir(test_dir)
copy_ref(test_dir)
Expand All @@ -185,11 +184,11 @@ def ref_multi_noaux(request, tmpdir):


@pytest.fixture
def ref_idtype(request):
def ref_idtype(request, tmp_path):
"""
Fixture that prepares the west.h5 file and also links in the "correct" istate dtype array.
"""
test_dir = tempfile.mkdtemp()
test_dir = str(tmp_path)
os.chdir(test_dir)

copy_ref(test_dir)
Expand All @@ -206,12 +205,12 @@ def ref_idtype(request):


@pytest.fixture
def ref_executable(request, tmpdir):
def ref_executable(request, tmp_path):
"""
Fixture that prepares a simulation directory with a populated west_executable.cfg file.
"""

test_dir = str(tmpdir)
test_dir = str(tmp_path)
os.chdir(test_dir)

copy_ref(test_dir)
Expand Down

0 comments on commit e5d847e

Please sign in to comment.