summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2022-06-14 13:34:48 -0700
committerSebastian Berg <sebastian@sipsolutions.net>2022-06-14 13:34:48 -0700
commitce94fb67fc31a095909310642da551f22456ab7b (patch)
treebf6e2fa9aee6e4e521a3347a1506a2fd99f5286f /numpy/lib/tests
parent820c6f4c5713a7ef92d48c66f8a58abd23cf6396 (diff)
downloadnumpy-ce94fb67fc31a095909310642da551f22456ab7b.tar.gz
TST: Clean up an opened temporary file descriptor in loadtxt tests
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_loadtxt.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_loadtxt.py b/numpy/lib/tests/test_loadtxt.py
index 8839ef0a8..2f191f145 100644
--- a/numpy/lib/tests/test_loadtxt.py
+++ b/numpy/lib/tests/test_loadtxt.py
@@ -5,6 +5,7 @@ These tests complement those found in `test_io.py`.
"""
import sys
+import os
import pytest
from tempfile import NamedTemporaryFile, mkstemp
from io import StringIO
@@ -960,9 +961,11 @@ def test_parametric_unit_discovery(
# file-obj path
fd, fname = mkstemp()
+ os.close(fd)
with open(fname, "w") as fh:
fh.write("\n".join(data))
a = np.loadtxt(fname, dtype=unitless_dtype)
+ os.remove(fname)
assert a.dtype == expected.dtype
assert_equal(a, expected)
@@ -982,9 +985,11 @@ def test_str_dtype_unit_discovery_with_converter():
# file-obj path
fd, fname = mkstemp()
+ os.close(fd)
with open(fname, "w") as fh:
fh.write("\n".join(data))
a = np.loadtxt(fname, dtype="U", converters=conv, encoding=None)
+ os.remove(fname)
assert a.dtype == expected.dtype
assert_equal(a, expected)