summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test__datasource.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2018-11-15 08:01:31 -0600
committerGitHub <noreply@github.com>2018-11-15 08:01:31 -0600
commitff8b0b21e0f17dbcc94fc87ba1194dcbbbe15432 (patch)
tree971b304cd89292c0209f399caaf8f650fd418180 /numpy/lib/tests/test__datasource.py
parentfcfadfe84058498c96408f0be487c70be8bba65e (diff)
parent470d53fc6bc8267fec7d7cf5c7116d5e7437d789 (diff)
downloadnumpy-ff8b0b21e0f17dbcc94fc87ba1194dcbbbe15432.tar.gz
Merge pull request #12381 from tylerjereddy/datasource_del_handling
BUG: graceful DataSource __del__ when __init__ fails
Diffstat (limited to 'numpy/lib/tests/test__datasource.py')
-rw-r--r--numpy/lib/tests/test__datasource.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/numpy/lib/tests/test__datasource.py b/numpy/lib/tests/test__datasource.py
index 1df8bebf6..8eac16b58 100644
--- a/numpy/lib/tests/test__datasource.py
+++ b/numpy/lib/tests/test__datasource.py
@@ -361,3 +361,18 @@ class TestOpenFunc(object):
fp = datasource.open(local_file)
assert_(fp)
fp.close()
+
+def test_del_attr_handling():
+ # DataSource __del__ can be called
+ # even if __init__ fails when the
+ # Exception object is caught by the
+ # caller as happens in refguide_check
+ # is_deprecated() function
+
+ ds = datasource.DataSource()
+ # simulate failed __init__ by removing key attribute
+ # produced within __init__ and expected by __del__
+ del ds._istmpdest
+ # should not raise an AttributeError if __del__
+ # gracefully handles failed __init__:
+ ds.__del__()