Skip to content

Commit c77c578

Browse files
committed
Replace Bunch class with MessageDetails
This change should make it a bit more explicit what form the message details are supposed to take.
1 parent bebb98b commit c77c578

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pytest_localserver/smtp.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616

1717
PY35_OR_NEWER = sys.version_info[:2] >= (3, 5)
1818

19+
20+
class MessageDetails:
21+
def __init__(self, peer, mailfrom, rcpttos, *, mail_options=None, rcpt_options=None):
22+
self.peer = peer
23+
self.mailfrom = mailfrom
24+
self.rcpttos = rcpttos
25+
if mail_options:
26+
self.mail_options = mail_options
27+
if rcpt_options:
28+
self.rcpt_options = rcpt_options
29+
30+
1931
class Server (smtpd.SMTPServer, threading.Thread):
2032

2133
"""
@@ -61,11 +73,7 @@ def process_message(self, peer, mailfrom, rcpttos, data, **kwargs):
6173
message = email.message_from_string(data)
6274
# on the message, also set the envelope details
6375

64-
class Bunch:
65-
def __init__(self, **kwds):
66-
vars(self).update(kwds)
67-
68-
message.details = Bunch(
76+
message.details = MessageDetails(
6977
peer=peer,
7078
mailfrom=mailfrom,
7179
rcpttos=rcpttos,

0 commit comments

Comments
 (0)