Skip to content

Commit

Permalink
Add test for accessing global namespace inside functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Apr 16, 2011
1 parent 66c14cf commit 3590d11
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions IPython/core/tests/test_interactiveshell.py
Expand Up @@ -102,6 +102,14 @@ def test_can_pickle(self):
from cPickle import dumps from cPickle import dumps
res = dumps(ip.user_ns["w"]) res = dumps(ip.user_ns["w"])
self.assertTrue(isinstance(res, bytes)) self.assertTrue(isinstance(res, bytes))

def test_global_ns(self):
ip = get_ipython()
ip.run_cell("a = 10")
ip.run_cell(("def f(x):"
" return x + a"))
ip.run_cell("b = f(12)")
self.assertEqual(ip.user_ns["b"], 22)






0 comments on commit 3590d11

Please sign in to comment.