diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/smtp_test_server/context.py b/smtp_test_server/context.py index 52d374b..917347d 100644 --- a/smtp_test_server/context.py +++ b/smtp_test_server/context.py @@ -2,12 +2,11 @@ Pytest Mock SMTP Server for testing """ from email.message import Message as EmailMessage -from typing import Optional +from typing import List, Optional from aiosmtpd.handlers import Message from smtp_test_server.exceptions import AlreadyStartedError, NotProperlyInitializedError, NotStartedError -from smtp_test_server.list import ThreadSafeMailList from smtp_test_server.mock import SmtpController from smtp_test_server.net import find_free_port @@ -22,7 +21,7 @@ class MessageKeeper(Message): Initialize with an empty message list """ super().__init__(*args, **kwargs) - self.__messages: ThreadSafeMailList[EmailMessage] = ThreadSafeMailList() + self.__messages: List[EmailMessage] = [] def handle_message(self, message: EmailMessage) -> None: """ @@ -31,7 +30,7 @@ class MessageKeeper(Message): self.__messages.append(message) @property - def messages(self) -> ThreadSafeMailList[EmailMessage]: + def messages(self) -> List[EmailMessage]: """ Access the messages list """ @@ -93,7 +92,7 @@ class SmtpMockServer: return self.__bind_port @property - def messages(self) -> ThreadSafeMailList[EmailMessage]: + def messages(self) -> List[EmailMessage]: """ Access the messages """ diff --git a/smtp_test_server/list.py b/smtp_test_server/list.py deleted file mode 100644 index 4fe7473..0000000 --- a/smtp_test_server/list.py +++ /dev/null @@ -1,32 +0,0 @@ -""" -Implementation of a thread safe list for mails -""" -import threading -from typing import TypeVar - -T = TypeVar("T") - - -class ThreadSafeMailList(list[T]): - """ - Simplified Mail List - """ - - def __init__(self, *args, **kwargs): - """ - List with locking - """ - super().__init__(*args, **kwargs) - self.__lock = threading.Lock() - - def append(self, __object: T): - with self.__lock: - super().append(__object) - - def __len__(self) -> int: - with self.__lock: - return super().__len__() - - def __getitem__(self, item) -> T: - with self.__lock: - return super().__getitem__(item)