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-08-16 13:12:32 -0600
commit0ade4c43f052247a2d12a2c49d3c846e6c429fa9 (patch)
tree9a392681beeb6e1b297e8563867068fb5fa1106d /numpy/tests/test_reloading.py
parent63d30baee2535f03d55a10819ea1e56165d4c030 (diff)
downloadnumpy-0ade4c43f052247a2d12a2c49d3c846e6c429fa9.tar.gz
BUG: Make sure numpy globals keep identity after reload.
Reloading currently causes problems because global classes defined in numpy/__init__.py change their identity (a is b) after reload. The solution taken here is to move those classes to a new non-reloadable module numpy/_globals and import them into numpy from there. Classes moved are ModuleDeprecationWarning, VisibleDeprecationWarning, and _NoValue. Closes #7844.
Diffstat (limited to 'numpy/tests/test_reloading.py')
-rw-r--r--numpy/tests/test_reloading.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/numpy/tests/test_reloading.py b/numpy/tests/test_reloading.py
index 141e11f6c..ca651c874 100644
--- a/numpy/tests/test_reloading.py
+++ b/numpy/tests/test_reloading.py
@@ -2,7 +2,6 @@ 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):
@@ -10,13 +9,22 @@ if sys.version_info[:2] >= (3, 4):
else:
from imp import reload
-def test_reloading_exception():
+def test_numpy_reloading():
# gh-7844. Also check that relevant globals retain their identity.
+ import numpy as np
+ import numpy._globals
+
_NoValue = np._NoValue
VisibleDeprecationWarning = np.VisibleDeprecationWarning
ModuleDeprecationWarning = np.ModuleDeprecationWarning
- assert_raises(RuntimeError, reload, np)
+ reload(np)
+ assert_(_NoValue is np._NoValue)
+ assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning)
+ assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)
+
+ assert_raises(RuntimeError, reload, numpy._globals)
+ reload(np)
assert_(_NoValue is np._NoValue)
assert_(ModuleDeprecationWarning is np.ModuleDeprecationWarning)
assert_(VisibleDeprecationWarning is np.VisibleDeprecationWarning)