'Testing whether the API returns a formatted 500 error if IOError is raised'

@deferred(timeout=10)
def test_create_torrent_io_error(self):

    def verify_error_message(body):
        error_response = json.loads(body)
        expected_response = {u'error': {u'handled': True, u'code': u'IOError', u'message': (u'Path    does    not    exist:    %s' % post_data['files[]'])}}
        self.assertDictContainsSubset(expected_response[u'error'], error_response[u'error'])
    post_data = {'files[]': 'non_existing_file.avi'}
    self.should_check_equality = False
    return self.do_request('createtorrent', 500, None, 'POST', post_data).addCallback(verify_error_message)
