Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clean up sys.path entry.

  • Loading branch information...
commit 2e6a444ff1b951c2180c70b32658ba73c78622b7 1 parent 807f609
@bfroehle authored
Showing with 18 additions and 17 deletions.
  1. +18 −17 IPython/lib/tests/test_deepreload.py
View
35 IPython/lib/tests/test_deepreload.py
@@ -11,6 +11,7 @@
import nose.tools as nt
from IPython.testing import decorators as dec
+from IPython.utils.syspathcontext import prepended_to_syspath
from IPython.utils.tempdir import TemporaryDirectory
from IPython.lib.deepreload import reload as dreload
@@ -33,20 +34,20 @@ def test_deepreload_numpy():
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'])
- nt.assert_true(isinstance(obj, A.Object))
-
- # Test that A is reloaded.
- obj = A.Object()
- dreload(B)
- nt.assert_false(isinstance(obj, A.Object))
+ with prepended_to_syspath(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'])
+ nt.assert_true(isinstance(obj, A.Object))
+
+ # Test that A is reloaded.
+ obj = A.Object()
+ dreload(B)
+ nt.assert_false(isinstance(obj, A.Object))
Please sign in to comment.
Something went wrong with that request. Please try again.