summaryrefslogtreecommitdiff
path: root/numpy/tests/test_reloading.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-07-20 11:09:36 -0600
committerCharles Harris <charlesr.harris@gmail.com>2016-07-20 11:23:15 -0600
commitb9b42ee958db9882c6490311aa47395b4b5e5922 (patch)
tree5b32399b2a526c32fd97e00cddd77314a2fb0e08 /numpy/tests/test_reloading.py
parent93240e0d8ea23644a5b7874037e658c54966ff54 (diff)
downloadnumpy-b9b42ee958db9882c6490311aa47395b4b5e5922.tar.gz
BUG: Raise RuntimeError when reloading numpy is attempted.
There seems to be little use in reloading numpy as any changed modules that are imported into numpy would need to be reloaded first in order to see any changes. Furthermore, reloading causes problems as global classes defined in numpy/__init__.py change their identity. Hence we raise a RuntimeError when an attempt to reload numpy is made. Closes #7844.
Diffstat (limited to 'numpy/tests/test_reloading.py')
-rw-r--r--numpy/tests/test_reloading.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/numpy/tests/test_reloading.py b/numpy/tests/test_reloading.py
new file mode 100644
index 000000000..141e11f6c
--- /dev/null
+++ b/numpy/tests/test_reloading.py
@@ -0,0 +1,26 @@
+from __future__ import division, absolute_import, print_function
+
+import sys
+
+import numpy as np
+from numpy.testing import assert_raises, assert_, run_module_suite
+
+if sys.version_info[:2] >= (3, 4):
+ from importlib import reload
+else:
+ from imp import reload
+
+def test_reloading_exception():
+ # gh-7844. Also check that relevant globals retain their identity.
+ _NoValue = np._NoValue
+ VisibleDeprecationWarning = np.VisibleDeprecationWarning
+ ModuleDeprecationWarning = np.ModuleDeprecationWarning
+
+ assert_raises(RuntimeError, reload, np)
+ assert_(_NoValue is np._NoValue)
+ assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning)
+ assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)
+
+
+if __name__ == "__main__":
+ run_module_suite()