Skip to content

Commit 13ce70c

Browse files
committed
small improvement
1 parent cb5d76c commit 13ce70c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

tests/engine/test_stats.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def add_variable_to_grib(filename, dict_data):
6565

6666

6767
@pytest.fixture
68-
def setup_grib_file():
68+
def setup_grib_file(tmp_dir):
6969
array_t = np.ones(
7070
(
7171
TIME_DIM_GRIB_SIZE,
@@ -94,11 +94,11 @@ def setup_grib_file():
9494
dict_data = {"t": array_pres, "v": array_t}
9595

9696
# This would be where your grib file is created
97-
add_variable_to_grib(GRIB_FILENAME, dict_data)
97+
add_variable_to_grib(os.path.join(tmp_dir, GRIB_FILENAME), dict_data)
9898

9999

100100
@pytest.mark.usefixtures("setup_grib_file")
101-
def test_stats():
101+
def test_stats_grib(tmp_dir):
102102
file_specification = {
103103
"Test data": {
104104
"format": "grib",
@@ -110,7 +110,7 @@ def test_stats():
110110
}
111111

112112
df = create_stats_dataframe(
113-
input_dir=".",
113+
input_dir=tmp_dir,
114114
file_id=[["Test data", GRIB_FILENAME]],
115115
stats_file_name=STATS_FILE_NAMES,
116116
file_specification=file_specification,
@@ -141,7 +141,6 @@ class TestStatsNetcdf(unittest.TestCase):
141141

142142
nc_file_name = "test_stats.nc"
143143
nc_file_glob = "test_s*.nc"
144-
stats_file_names = "test_stats.csv"
145144

146145
def setUp(self):
147146
data = initialize_dummy_netcdf_file(self.nc_file_name)
@@ -168,7 +167,7 @@ def setUp(self):
168167

169168
def tear_down(self):
170169
os.remove(self.nc_file_name)
171-
os.remove(self.stats_file_names)
170+
os.remove(STATS_FILE_NAMES)
172171

173172
def test_stats(self):
174173
file_specification = {
@@ -183,7 +182,7 @@ def test_stats(self):
183182
df = create_stats_dataframe(
184183
input_dir=".",
185184
file_id=[["Test data", self.nc_file_glob]],
186-
stats_file_name=self.stats_file_names,
185+
stats_file_name=STATS_FILE_NAMES,
187186
file_specification=file_specification,
188187
)
189188

0 commit comments

Comments
 (0)