diff --git a/IPython/core/magic.py b/IPython/core/magic.py index 057f48b..0e071cb 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -727,6 +727,7 @@ Currently the magic system has the following functions:\n""" 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 @@ Currently the magic system has the following functions:\n""" 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 @@ Currently the magic system has the following functions:\n""" print print + @testdec.skip_doctest def magic_whos(self, parameter_s=''): """Like %who, but gives some extra information about each variable. diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index 02af20e..486b5d7 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -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'] + """ \ No newline at end of file