File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -731,6 +731,20 @@ def __repr__(self):
731731 _ip .user_ns ["a" ] = A ()
732732 _ip .run_line_magic ("whos" , "" )
733733
734+ def test_whos1 ():
735+ ip = get_ipython ()
736+ ip .user_ns ["shortstr" ] = "The quick brown fox jumps over the lazy dog"
737+ ip .user_ns ["longstr" ] = " " .join (["The quick brown fox jumps over the lazy dog" ]* 2 )
738+ expected_short = ip .user_ns ["shortstr" ]
739+ expected_long = "The quick brown fox jumps<...>x jumps over the lazy dog"
740+ with capture_output () as captured :
741+ ip .run_line_magic ("whos" ,"" )
742+ stdout = captured .stdout
743+ ## s = " ".join([l for l in stdout.splitlines() if l.startswith('longstr') ][0].split()[2:])
744+ long = " " .join (re .split (r"\s+str\s+" ,[l for l in stdout .splitlines () if l .startswith ('longstr' ) ][0 ])[1 :])
745+ short = " " .join (re .split (r"\s+str\s+" ,[l for l in stdout .splitlines () if l .startswith ('shortstr' ) ][0 ])[1 :])
746+ assert long == expected_long
747+ assert short == expected_short
734748
735749def doctest_precision ():
736750 """doctest for %precision
You can’t perform that action at this time.
0 commit comments