diff options
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test_io.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 04ca3fb4e..949d8fb45 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -6,6 +6,7 @@ from tempfile import mkstemp, NamedTemporaryFile import time from datetime import datetime import warnings +import gc from numpy.testing.utils import WarningManager import numpy as np @@ -1525,6 +1526,20 @@ def test_npzfile_dict(): assert_('x' in list(z.iterkeys())) +def test_load_refcount(): + # Check that objects returned by np.load are directly freed based on + # their refcount, rather than needing the gc to collect them. + + f = StringIO() + np.savez(f, [1, 2, 3]) + f.seek(0) + + gc.collect() + n_before = len(gc.get_objects()) + np.load(f) + n_after = len(gc.get_objects()) + + assert_equal(n_before, n_after) if __name__ == "__main__": run_module_suite() |