'Can we pickle objects defined interactively (GH-29)'

def test_can_pickle(self):

    ip = get_ipython()
    ip.reset()
    ip.run_cell('class    Mylist(list):\n                def    __init__(self,x=[]):\n                                list.__init__(self,x)')
    ip.run_cell('w=Mylist([1,2,3])')
    from pickle import dumps
    _main = sys.modules['__main__']
    sys.modules['__main__'] = ip.user_module
    try:
        res = dumps(ip.user_ns['w'])
    finally:
        sys.modules['__main__'] = _main
    self.assertTrue(isinstance(res, bytes))
