-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added try/except block to handle authentication errors #17
Conversation
@trp07 Added 'raise' statement to try/except block in _get_session method. |
…eally getting back error response. Instead we use mock
tests/test_email.py
Outdated
e = get_email | ||
|
||
with pytest.raises(SMTPResponseException): | ||
print('Exception was not raised, but it should be.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get rid of this print statement
tests/test_email.py
Outdated
e = get_email | ||
|
||
with pytest.raises(Exception): | ||
print('Exception was not raised, but it should be.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get rid of this print statement
messages/email_.py
Outdated
try: | ||
session.login(self.from_, self._auth) | ||
except SMTPResponseException as e: | ||
# decodes bytestring from response to unicode string for readability |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get rid of this comment
Prints removed. |
@trp07 Should be good now |
messages/email_.py
Outdated
@@ -18,6 +18,7 @@ | |||
from ._utils import credential_property | |||
from ._utils import validate_property | |||
from ._utils import timestamp | |||
from smtplib import SMTPResponseException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reorder this to be underneath the "import smtplib" at the top. Typical import hierarchy from top-to-bottom goes: standard library modules, then third-party modules, then internal package modules.
@Mat001, thanks a ton for the work. I added a few comments. |
Thanks! |
@trp07 Added try/except block in _get_session() method.
It handles auth errors such as incorrect password.Per: https://docs.python.org/3.6/library/smtplib.html#smtplib.SMTPResponseException