##// END OF EJS Templates
Fix deepreload tests in Python 2.6....
Fix deepreload tests in Python 2.6. Apparently assert_is_instance and assert_not_is_instance are not available in Python 2.6.

File last commit:

r6540:807f6092
r6540:807f6092
Show More
test_deepreload.py
52 lines | 1.6 KiB | text/x-python | PythonLexer
/ IPython / lib / tests / test_deepreload.py
Bradley M. Froehle
Reformat test to a standard style.
r6534 # -*- coding: utf-8 -*-
Bradley M. Froehle
Add deepreload unit test....
r6533 """Test suite for the deepreload module."""
Bradley M. Froehle
Reformat test to a standard style.
r6534 #-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
Bradley M. Froehle
Add deepreload functionality test.
r6535 import os
import sys
import nose.tools as nt
Bradley M. Froehle
Add deepreload unit test....
r6533 from IPython.testing import decorators as dec
Bradley M. Froehle
Add deepreload functionality test.
r6535 from IPython.utils.tempdir import TemporaryDirectory
Bradley M. Froehle
Add deepreload unit test....
r6533 from IPython.lib.deepreload import reload as dreload
Bradley M. Froehle
Reformat test to a standard style.
r6534 #-----------------------------------------------------------------------------
# Test functions begin
#-----------------------------------------------------------------------------
Bradley M. Froehle
Add deepreload unit test....
r6533 @dec.skipif_not_numpy
def test_deepreload_numpy():
Bradley M. Froehle
Add deepreload functionality test.
r6535 "Test that NumPy can be deep reloaded."
Bradley M. Froehle
Add deepreload unit test....
r6533 import numpy
exclude = [
# Standard exclusions:
'sys', 'os.path', '__builtin__', '__main__',
# Test-related exclusions:
'unittest',
]
dreload(numpy, exclude=exclude)
Bradley M. Froehle
Add deepreload functionality test.
r6535
def test_deepreload():
"Test that dreload does deep reloads and skips excluded modules."
with TemporaryDirectory() as tmpdir:
sys.path.insert(0, tmpdir)
with open(os.path.join(tmpdir, 'A.py'), 'w') as f:
f.write("class Object(object):\n pass\n")
with open(os.path.join(tmpdir, 'B.py'), 'w') as f:
f.write("import A\n")
import A
import B
# Test that A is not reloaded.
obj = A.Object()
dreload(B, exclude=['A'])
Bradley M. Froehle
Fix deepreload tests in Python 2.6....
r6540 nt.assert_true(isinstance(obj, A.Object))
Bradley M. Froehle
Add deepreload functionality test.
r6535
# Test that A is reloaded.
obj = A.Object()
dreload(B)
Bradley M. Froehle
Fix deepreload tests in Python 2.6....
r6540 nt.assert_false(isinstance(obj, A.Object))