'Test that namespace cleanup is not too aggressive GH-238
Returning from another run magic deletes the namespace'

def test_aggressive_namespace_cleanup(self):

    with tt.TempFileMixin() as empty:
        empty.mktmp('')
        src = ('ip    =    get_ipython()\nfor    i    in    range(5):\n            try:\n                            ip.magic(%r)\n            except    NameError    as    e:\n                            print(i)\n                            break\n' % ('run    ' + empty.fname))
        self.mktmp(src)
        _ip.magic(('run    %s' % self.fname))
        _ip.run_cell('ip    ==    get_ipython()')
        nt.assert_equal(_ip.user_ns['i'], 4)
