def startMockS3Server():
    # Reduce the chunk size to allow faster testing.
    S3AssetstoreAdapter.CHUNK_LEN = 1024 * 256
    moto.s3.models.UPLOAD_PART_MIN_SIZE = 1024 * 256
    # turn off logging from the S3 server unless we've asked to keep it
    if 'mocks3' not in os.environ.get('EXTRADEBUG', '').split():
        logging.getLogger('werkzeug').setLevel(logging.CRITICAL)
    selectedPort = None
    for porttry in range(_maxTries):
        port = _startPort + ((porttry + os.getpid()) % _maxTries)
        test_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            test_socket.bind(('0.0.0.0', port))
            selectedPort = port
        except socket.error as err:
            # Allow address in use errors to fail quietly
            if err.errno != errno.EADDRINUSE:
                raise
        test_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        test_socket.close()
        if selectedPort is not None:
            break
    server = MockS3Server(selectedPort)
    server.start()
    # add a bucket named 'bucketname' to simplify testing
    createBucket(server.botoConnect, 'bucketname')
    return server
Testing HostingServiceHook initializing
dataset/ETHPy150Open girder/girder/tests/mock_s3.py/startMockS3Server--crossover with--dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/extensions/tests.py/HostingServiceHookTests.test_register