44import time
55
66from moto import mock_aws
7-
87from six .moves import range
98import pytest
109
1817from taskqueue .queueables import totask
1918from taskqueue .queueablefns import tofunc , UnregisteredFunctionError , func2task
2019
21- @pytest .fixture (scope = 'function ' )
20+ @pytest .fixture (scope = 'session ' )
2221def aws_credentials ():
2322 """Mocked AWS Credentials for moto."""
2423 os .environ ['AWS_ACCESS_KEY_ID' ] = 'testing'
@@ -35,6 +34,21 @@ def sqs(aws_credentials):
3534 client .create_queue (QueueName = 'test-pull-queue' )
3635 yield client
3736
37+ @pytest .fixture (scope = 'session' )
38+ def sqs_server (aws_credentials ):
39+ from moto .server import ThreadedMotoServer
40+ import boto3
41+ server = ThreadedMotoServer (port = 0 )
42+ server .start ()
43+ host , port = server .get_host_and_port ()
44+ endpoint = f"http://{ host } :{ port } "
45+ os .environ ['AWS_ENDPOINT_URL' ] = endpoint
46+ client = boto3 .client ('sqs' , endpoint_url = endpoint )
47+ client .create_queue (QueueName = 'test-pull-queue' )
48+ yield client
49+ del os .environ ['AWS_ENDPOINT_URL' ]
50+ server .stop ()
51+
3852QURLS = {
3953 'sqs' : 'test-pull-queue' ,
4054 'fq' : '/tmp/removeme/taskqueue/fq' ,
@@ -269,7 +283,7 @@ def test_local_taskqueue():
269283 assert tq .insert (epts ) == 200
270284
271285@pytest .mark .parametrize ('protocol' , PROTOCOL )
272- def test_parallel_insert_all (sqs , protocol ):
286+ def test_parallel_insert_all (sqs_server , protocol ):
273287 import pathos_issue
274288
275289 path = getpath (protocol )
0 commit comments