Skip to content

Commit

Permalink
TST: add regression test for scipygh-1550 (netcdf_file leaves mmaps o…
Browse files Browse the repository at this point in the history
…pen).
  • Loading branch information
rgommers committed Dec 21, 2013
1 parent a132b8e commit cda8208
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions scipy/io/tests/test_netcdf.py
Expand Up @@ -5,14 +5,12 @@
from os.path import join as pjoin, dirname
import shutil
import tempfile
import time
import sys
from io import BytesIO
from glob import glob
from contextlib import contextmanager

import numpy as np
from numpy.testing import dec, assert_, assert_allclose
from numpy.testing import assert_, assert_allclose

from scipy.io.netcdf import netcdf_file

Expand Down Expand Up @@ -198,3 +196,14 @@ def test_ticket_1720():
assert_equal(float_var.units, b'metres')
assert_equal(float_var.shape, (10,))
assert_allclose(float_var[:], items)


def test_mmaps_closed():
# Regression test for gh-1550. Will fail with "Too many open files"
# error if not all mmaps aren't closed by ``f.close()``.
filename = pjoin(TEST_DATA_PATH, 'example_1.nc')
vars = []
for i in range(1100):
f = netcdf_file(filename, mmap=True)
vars.append(f.variables['lat'])
f.close()

0 comments on commit cda8208

Please sign in to comment.