Compare commits

...

2 Commits

Author SHA1 Message Date
2c6d98ce2d fix warning in tests 2024-04-02 16:47:41 -04:00
520dfd7b14 remove unused imports 2024-04-02 16:35:47 -04:00
4 changed files with 11 additions and 14 deletions

View File

@ -2,11 +2,8 @@ import asyncio
import contextlib
import contextvars
import logging
import os
import ssl
import uuid
from dataclasses import dataclass
from hashlib import sha256
from pathlib import Path
from .config import User
from .pwhash import parse_hash, check_pass, PWInfo

View File

@ -1,8 +1,6 @@
import asyncio
import logging
import os
import ssl
import sys
from argparse import ArgumentParser
from pathlib import Path
from getpass import getpass

View File

@ -1,7 +1,5 @@
import asyncio
import io
import logging
import mailbox
import ssl
import uuid
import shutil
@ -13,11 +11,9 @@ from email.message import Message
import email.policy
from email.generator import BytesGenerator
import tempfile
import random
from aiosmtpd.handlers import Mailbox, AsyncMessage
from aiosmtpd.smtp import SMTP, DATA_SIZE_DEFAULT
from aiosmtpd.smtp import SMTP as SMTPServer
from aiosmtpd.handlers import AsyncMessage
from aiosmtpd.smtp import SMTP
from aiosmtpd.smtp import Envelope as SMTPEnvelope
from aiosmtpd.smtp import Session as SMTPSession
@ -31,7 +27,7 @@ class MyHandler(AsyncMessage):
self.mbox_finder = mbox_finder
async def handle_DATA(
self, server: SMTPServer, session: SMTPSession, envelope: SMTPEnvelope
self, server: SMTP, session: SMTPSession, envelope: SMTPEnvelope
) -> str:
self.rcpt_tos = envelope.rcpt_tos
self.peer = session.peer

View File

@ -89,6 +89,9 @@ class TestPop3(unittest.IsolatedAsyncioTestCase):
self.task = asyncio.create_task(pop_server.serve_forever())
self.reader, self.writer = await asyncio.open_connection("127.0.0.1", 7995)
# Additional writers to close
self.ws: list[asyncio.StreamWriter] = []
async def test_QUIT(self) -> None:
dialog = """
S: +OK Server Ready
@ -133,6 +136,7 @@ class TestPop3(unittest.IsolatedAsyncioTestCase):
async def test_dupe_AUTH(self) -> None:
r1, w1 = await asyncio.open_connection("127.0.0.1", 7995)
r2, w2 = await asyncio.open_connection("127.0.0.1", 7995)
self.ws += w1, w2
dialog = """
S: +OK Server Ready
C: USER foobar
@ -231,8 +235,10 @@ class TestPop3(unittest.IsolatedAsyncioTestCase):
async def asyncTearDown(self) -> None:
logging.debug("at teardown")
self.writer.close()
await self.writer.wait_closed()
for w in self.ws + [self.writer]:
w.close()
await w.wait_closed()
self.ws.clear()
self.task.cancel("test done")
async def dialog_checker(self, dialog: str) -> None: