{"action":"closed","issue":{"url":"https://api.github.com/repos/tornadoweb/tornado/issues/1466","labels_url":"https://api.github.com/repos/tornadoweb/tornado/issues/1466/labels{/name}","comments_url":"https://api.github.com/repos/tornadoweb/tornado/issues/1466/comments","events_url":"https://api.github.com/repos/tornadoweb/tornado/issues/1466/events","html_url":"https://github.com/tornadoweb/tornado/issues/1466","id":96702052,"number":1466,"title":"AttributeError when overriding get_new_ioloop with more than one test","user":{"login":"rsmith31415","id":599274,"avatar_url":"https://avatars.githubusercontent.com/u/599274?v=3","gravatar_id":"","url":"https://api.github.com/users/rsmith31415","html_url":"https://github.com/rsmith31415","followers_url":"https://api.github.com/users/rsmith31415/followers","following_url":"https://api.github.com/users/rsmith31415/following{/other_user}","gists_url":"https://api.github.com/users/rsmith31415/gists{/gist_id}","starred_url":"https://api.github.com/users/rsmith31415/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsmith31415/subscriptions","organizations_url":"https://api.github.com/users/rsmith31415/orgs","repos_url":"https://api.github.com/users/rsmith31415/repos","events_url":"https://api.github.com/users/rsmith31415/events{/privacy}","received_events_url":"https://api.github.com/users/rsmith31415/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-23T01:09:05Z","updated_at":"2015-07-23T17:43:19Z","closed_at":"2015-07-23T17:43:19Z","body":"I believe this is an old issue in which overriding `get_new_ioloop` in `AsyncHTTPTestCase` throws `AttributeError: 'NoneType' object has no attribute done` when there are more than one test in the class (that is, the first test actually passes correctly but other tests output the previous error). This is a sample code:\r\n\r\n```\r\nimport tornado.web\r\nimport tornado.gen\r\nimport tornado.websocket\r\nimport tornado.httpserver\r\nimport tornado.ioloop \r\n\r\nimport json\r\nimport time\r\n\r\nfrom tornado.testing import gen_test\r\nfrom tornado.testing import AsyncHTTPTestCase\r\nfrom tornado import websocket\r\n\r\nclass EchoWebSocket(tornado.websocket.WebSocketHandler):\r\n    def open(self):\r\n        print(\"WebSocket opened\")\r\n\r\n    def on_message(self, message):\r\n        message = json.loads(message)\r\n\r\n        tornado.ioloop.IOLoop.current().add_callback(lambda: self.write_message(message))\r\n\r\n    def on_close(self):\r\n        print(\"WebSocket closed\")\r\n\r\n\r\nclass Application(tornado.web.Application):\r\n    def __init__(self):\r\n\r\n        handlers = [\r\n            (r'/websocket', EchoWebSocket),\r\n        ]\r\n        settings = {\r\n            'debug': True,\r\n        }\r\n\r\n        tornado.web.Application.__init__(self, handlers, **settings)\r\n\r\n\r\nif __name__ == '__main__':\r\n    tornado.options.parse_command_line()\r\n    app = Application()\r\n    app.listen(8000)\r\n\r\n    try:\r\n        tornado.ioloop.IOLoop.current().start()\r\n    except:\r\n        pass\r\n    finally:\r\n        tornado.ioloop.IOLoop.current().stop()\r\n\r\nclass TestEchoWebSocket(AsyncHTTPTestCase):\r\n    def get_app(self):\r\n        self.application = Application()\r\n        return self.application\r\n\r\n    def get_new_ioloop(self):\r\n        return tornado.ioloop.IOLoop.current()\r\n\r\n    def setUp(self):\r\n        super(TestEchoWebSocket, self).setUp()\r\n\r\n    def tearDown(self):\r\n        tornado.ioloop.IOLoop.current().stop()\r\n\r\n    @gen_test()\r\n    def test_websocket_1(self):\r\n        url = \"ws://localhost:%d/websocket\" % self.get_http_port()\r\n        ws = yield websocket.websocket_connect(url, io_loop=self.io_loop)\r\n        data = {'value': '1'}\r\n        data = json.dumps(data)\r\n        ws.write_message(data)\r\n        response = yield ws.read_message()\r\n        response = json.loads(response)\r\n        self.assertEqual(response['value'], \"1\")\r\n\r\n    @gen_test\r\n    def test_websocket_2(self):\r\n        url = \"ws://localhost:%d/websocket\" % self.get_http_port()\r\n        ws = yield websocket.websocket_connect(url, io_loop=self.io_loop)\r\n        data = {'value': '1'}\r\n        data = json.dumps(data)\r\n        ws.write_message(data)\r\n        response = yield ws.read_message()\r\n        response = json.loads(response)\r\n        self.assertEqual(response['value'], \"1\")\r\n```\r\n```\r\n.E\r\n======================================================================\r\nERROR: test_websocket_2 (tornado_addcallback_test2.TestEchoWebSocket)\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n  File \"/home/user/anaconda/envs/tornado-environment/lib/python2.7/site-packages/tornado/testing.py\", line 120, in __call__\r\n    result = self.orig_method(*args, **kwargs)\r\n  File \"/home/user/anaconda/envs/tornado-environment/lib/python2.7/site-packages/tornado/testing.py\", line 503, in post_coroutine\r\n    timeout=timeout)\r\n  File \"/home/user/anaconda/envs/tornado-environment/lib/python2.7/site-packages/tornado/ioloop.py\", line 419, in run_sync\r\n    if not future_cell[0].done():\r\nAttributeError: 'NoneType' object has no attribute 'done'\r\n\r\n----------------------------------------------------------------------\r\nRan 2 tests in 0.013s\r\n\r\nFAILED (errors=1)\r\n```\r\n\r\nI don't think this is related to websockets, but that is what I have to reproduce this issue. I tried to use `tornado.ioloop.IOLoop.current()` instead of `tornado.ioloop.IOLoop.instance()` but the problem remains. I also tried to see if `tornado.ioloop.IOLoop.current().add_callback(lambda: self.write_message(message))` was somehow related but using `self.write_message(message)` throws the same error. How can I fix this issue?"}}