Skip to content

Commit

Permalink
[test] use tmpdir instead of tempfile
Browse files Browse the repository at this point in the history
  • Loading branch information
TakuyaNarihira committed Aug 8, 2018
1 parent c64402f commit c308fa2
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions python/test/test_nnp_graph.py
Expand Up @@ -21,7 +21,7 @@


@pytest.mark.parametrize("seed", [313])
def test_nnp_graph(seed):
def test_nnp_graph(seed, tmpdir):

rng = np.random.RandomState(seed)

Expand All @@ -43,18 +43,14 @@ def unit(i, prefix):
'outputs': {'y': y},
'names': {'x': x}}],
}
import tempfile
tmpdir = tempfile.mkdtemp()
import os
nnp_file = os.path.join(tmpdir, 'tmp.nnp')
try:
from nnabla.utils.save import save
save(nnp_file, runtime_contents)
from nnabla.utils import nnp_graph
nnp = nnp_graph.NnpLoader(nnp_file)
finally:
import shutil
shutil.rmtree(tmpdir)
tmpdir.ensure(dir=True)
nnp_file = tmpdir.join('tmp.nnp').strpath

from nnabla.utils.save import save
save(nnp_file, runtime_contents)
from nnabla.utils import nnp_graph
nnp = nnp_graph.NnpLoader(nnp_file)

graph = nnp.get_network('graph')
x2 = graph.inputs['x']
y2 = graph.outputs['y']
Expand Down

0 comments on commit c308fa2

Please sign in to comment.