#NEWLINE# def startMockS3Server( ) : #NEWLINE# #INDENT# '\n    Start a server using the defaults and adding a configuration parameter to\n    the system so that the s3 assetstore handler will know to use this\n    server.  Attempt to bind to any port within the range specified by\n    _startPort and _maxTries.  Bias it with the pid of the current process so\n    as to reduce potential conflicts with parallel tests that are started\n    nearly simultaneously.\n\n    :returns: the started server.\n    ' #NEWLINE# S3AssetstoreAdapter . CHUNK_LEN = ( 1024 * 256 ) #NEWLINE# moto . s3 . models . UPLOAD_PART_MIN_SIZE = ( 1024 * 256 ) #NEWLINE# if ( 'mocks3' not in os . environ . get ( 'EXTRADEBUG' , '' ) . split ( ) ) : #NEWLINE# #INDENT# logging . getLogger ( 'werkzeug' ) . setLevel ( logging . CRITICAL ) #NEWLINE# #UNINDENT# selectedPort = None #NEWLINE# for porttry in range ( _maxTries ) : #NEWLINE# #INDENT# port = ( _startPort + ( ( porttry + os . getpid ( ) ) % _maxTries ) ) #NEWLINE# test_socket = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) #NEWLINE# try : #NEWLINE# #INDENT# test_socket . bind ( ( '0.0.0.0' , port ) ) #NEWLINE# selectedPort = port #NEWLINE# #UNINDENT# except socket . error as err : #NEWLINE# #INDENT# if ( err . errno != errno . EADDRINUSE ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# test_socket . setsockopt ( socket . SOL_SOCKET , socket . SO_REUSEADDR , 1 ) #NEWLINE# test_socket . close ( ) #NEWLINE# if ( selectedPort is not None ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# server = MockS3Server ( selectedPort ) #NEWLINE# server . start ( ) #NEWLINE# createBucket ( server . botoConnect , 'bucketname' ) #NEWLINE# return server