Permalink
Browse files

Tweak IPython doctesting so it doesn't interfere with our other tests.

  • Loading branch information...
1 parent 3590d11 commit 7977a473edf3a9be252847c0f88618c0890a3dc4 @takluyver committed Apr 16, 2011
Showing with 4 additions and 0 deletions.
  1. +4 −0 IPython/testing/plugin/ipdoctest.py
@@ -271,6 +271,8 @@ def setUp(self):
# for IPython examples *only*, we swap the globals with the ipython
# namespace, after updating it with the globals (which doctest
# fills with the necessary info from the module being tested).
+ self.user_ns_orig = {}
+ self.user_ns_orig.update(_ip.user_ns)
_ip.user_ns.update(self._dt_test.globs)
self._dt_test.globs = _ip.user_ns
# IPython must protect the _ key in the namespace (it can't exist)
@@ -286,6 +288,8 @@ def tearDown(self):
# teardown doesn't destroy the ipython namespace
if isinstance(self._dt_test.examples[0],IPExample):
self._dt_test.globs = self._dt_test_globs_ori
+ _ip.user_ns.clear()
+ _ip.user_ns.update(self.user_ns_orig)
# Restore the behavior of the '_' key in the user namespace to
# normal after each doctest, so that unittests behave normally
_ip.user_ns.protect_underscore = False

0 comments on commit 7977a47

Please sign in to comment.