Permalink
Browse files

fix+test %who_ls type checking, skip %who doctests

due to new docstring output being based on clean user_ns.

closes gh-228
  • Loading branch information...
1 parent 96dd354 commit b6416bc27c15ce9117d1df566ed75ea9b13f16c1 @minrk minrk committed Feb 14, 2011
Showing with 29 additions and 1 deletion.
  1. +4 −1 IPython/core/magic.py
  2. +25 −0 IPython/core/tests/test_magic.py
View
@@ -727,6 +727,7 @@ def magic_psearch(self, parameter_s=''):
except:
shell.showtraceback()
+ @testdec.skip_doctest
def magic_who_ls(self, parameter_s=''):
"""Return a sorted list of all interactive variables.
@@ -762,11 +763,12 @@ def magic_who_ls(self, parameter_s=''):
typelist = parameter_s.split()
if typelist:
typeset = set(typelist)
- out = [i for i in out if type(i).__name__ in typeset]
+ out = [i for i in out if type(user_ns[i]).__name__ in typeset]
out.sort()
return out
+ @testdec.skip_doctest
def magic_who(self, parameter_s=''):
"""Print all interactive variables, with some minimal formatting.
@@ -827,6 +829,7 @@ def magic_who(self, parameter_s=''):
print
print
+ @testdec.skip_doctest
def magic_whos(self, parameter_s=''):
"""Like %who, but gives some extra information about each variable.
@@ -362,3 +362,28 @@ def test_xmode():
for i in range(3):
_ip.magic("xmode")
nt.assert_equal(_ip.InteractiveTB.mode, xmode)
+
+def doctest_who():
+ """doctest for %who
+
+ In [1]: %reset -f
+
+ In [2]: alpha = 123
+
+ In [3]: beta = 'beta'
+
+ In [4]: %who int
+ alpha
+
+ In [5]: %who str
+ beta
+
+ In [6]: %whos
+ Variable Type Data/Info
+ ----------------------------
+ alpha int 123
+ beta str beta
+
+ In [7]: %who_ls
+ Out[7]: ['alpha', 'beta']
+ """

0 comments on commit b6416bc

Please sign in to comment.