Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_raise_smtp_exception(message):
with pytest.raises(SMTPException) as excinfo:
raise SMTPException(message)
assert excinfo.value.message == message
def test_raise_smtp_exception(message):
with pytest.raises(SMTPException) as excinfo:
raise SMTPException(message)
assert excinfo.value.message == message
async def test_starttls_not_supported(
smtp_client, smtpd_server, smtpd_class, smtpd_response_handler_factory, monkeypatch
):
response_handler = smtpd_response_handler_factory(
"{} HELP".format(SMTPStatus.completed)
)
monkeypatch.setattr(smtpd_class, "smtp_EHLO", response_handler)
async with smtp_client:
await smtp_client.ehlo()
with pytest.raises(SMTPException):
await smtp_client.starttls(validate_certs=False)
async def test_starttls_advertised_but_not_supported(
smtp_client, smtpd_server, smtpd_class, smtpd_response_handler_factory, monkeypatch
):
response_handler = smtpd_response_handler_factory(
"{} please login".format(SMTPStatus.tls_not_available)
)
monkeypatch.setattr(smtpd_class, "smtp_STARTTLS", response_handler)
async with smtp_client:
await smtp_client.ehlo()
with pytest.raises(SMTPException):
await smtp_client.starttls(validate_certs=False)
def test_raise_smtp_not_supported(message):
with pytest.raises(SMTPNotSupported) as excinfo:
raise SMTPNotSupported(message)
assert issubclass(excinfo.type, SMTPException)
assert excinfo.value.message == message