Fix filename collisions in io_utils tests.
'''Tests for functions in io_utils.py.
'''
import os
-import sys
import pytest
from keras.models import Sequential
from keras.layers import Dense
@@ -13,6 +12,7 @@ import numpy as np
import six
import warnings
import h5py
+import tempfile
try:
from unittest.mock import patch
except:
@@ -46,7 +46,7 @@ def test_io_utils(in_tmpdir):
'''Tests the HDF5Matrix code using the sample from @jfsantos at
https://gist.github.com/jfsantos/e2ef822c744357a4ed16ec0c885100a3
'''
- h5_path = 'test.h5'
+ _, h5_path = tempfile.mkstemp('.h5')
create_dataset(h5_path)
# Instantiating HDF5Matrix for the training set,
@@ -135,7 +135,9 @@ def test_ask_to_proceed_with_overwrite():
assert not ask_to_proceed_with_overwrite('/tmp/not_exists')
-def test_h5dict_attrs(h5_path='test.h5'):
+def test_h5dict_attrs():
+ _, h5_path = tempfile.mkstemp('.h5')
+
# test both HDF5 and dict implementations
paths = [h5_path, dict()]
@@ -163,7 +165,9 @@ def test_h5dict_attrs(h5_path='test.h5'):
f.close()
-def test_h5dict_groups(h5_path='test.h5'):
+def test_h5dict_groups():
+ _, h5_path = tempfile.mkstemp('.h5')
+
# test both HDF5 and dict implementations
paths = [h5_path, dict()]
