Skip to content

Commit

Permalink
Merge pull request #774 from vidartf/FIX_test_tmpfile
Browse files Browse the repository at this point in the history
Forces GC as memmaps close filehandle on deletion
  • Loading branch information
francisco-dlp committed Dec 4, 2015
2 parents 70831aa + 6aab31c commit 4bbbc95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions hyperspy/tests/io/test_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from os import remove
import datetime
import h5py
import gc

import nose.tools as nt
import numpy as np
Expand Down Expand Up @@ -209,6 +210,7 @@ def test_general_type_not_working(self):
nt.assert_is_instance(l.metadata.test[2], unicode)

def tearDown(self):
gc.collect() # Make sure any memmaps are closed first!
remove('tmp.hdf5')


Expand Down Expand Up @@ -259,4 +261,5 @@ def test_oom_loading(self):
nt.assert_is_instance(s.data, h5py.Dataset)

def tearDown(self):
gc.collect() # Make sure any memmaps are closed first!
remove('tmp.hdf5')
5 changes: 3 additions & 2 deletions hyperspy/tests/model/test_model_storing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import nose.tools as nt
from hyperspy._signals.spectrum import Spectrum
from hyperspy.io import load
from hyperspy.components import Gaussian, Lorentzian
from hyperspy.components import Gaussian
import mock
import gc


def clean_model_dictionary(d):
Expand Down Expand Up @@ -150,12 +151,12 @@ def setUp(self):

def test_save_and_load_model(self):
m = self.m
s = m.spectrum
m.save('tmp.hdf5')
l = load('tmp.hdf5')
nt.assert_true(hasattr(l.models, 'a'))
n = l.models.restore('a')
nt.assert_equal(n.components.something.A.value, 13)

def tearDown(self):
gc.collect() # Make sure any memmaps are closed first!
remove('tmp.hdf5')

0 comments on commit 4bbbc95

Please sign in to comment.