Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion tests/conftest.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,6 +27,7 @@

import os
import re
import socket
import string
import uuid
from datetime import datetime
Expand DownExpand Up@@ -1587,7 +1588,7 @@ def fixture_aws_credentials() -> Generator[None, None, None]:
os.environ.pop("AWS_DEFAULT_REGION")


MOTO_SERVER = ThreadedMotoServer(ip_address="localhost", port=5000)
MOTO_SERVER = ThreadedMotoServer(ip_address="localhost", port=5001)


def pytest_sessionfinish(
Expand All@@ -1600,10 +1601,17 @@ def pytest_sessionfinish(

@pytest.fixture(scope="session")
def moto_server() -> ThreadedMotoServer:
# this will throw an exception if the port is already in use
is_port_in_use(MOTO_SERVER._ip_address, MOTO_SERVER._port)
MOTO_SERVER.start()
return MOTO_SERVER


def is_port_in_use(ip_address: str, port: int) -> None:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((ip_address, port))


@pytest.fixture(scope="session")
def moto_endpoint_url(moto_server: ThreadedMotoServer) -> str:
_url = f"http://{moto_server._ip_address}:{moto_server._port}"
Expand Down