Skip to content

Commit 5ef2853

Browse files
committed
[test]: skip TestEmailCallback tests for py3.7 (or below)
the mock object of mock.patch(smtplib.SMTP) has no args attribute available for py3.7 or below. probably need to find a more generic testing strategy here
1 parent f4f89e2 commit 5ef2853

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tests/callbacks/test_email.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
import sys
12
from unittest import mock
23

4+
import pytest
35
import tensorflow as tf
46

57
from tf_notify import EmailCallback
68

79

810
class TestEmailCallback:
11+
@pytest.mark.skipif(
12+
sys.version_info < (3, 8), reason="requires python3.8 or higher"
13+
)
914
def test_callback_occurs_on_train_end(self):
1015

1116
# define tf.keras model to add callback to
@@ -53,7 +58,10 @@ def test_callback_occurs_on_train_end(self):
5358
login, send_message = smtp_mock.method_calls
5459

5560
# one time to authenticate against the SMTP server
56-
assert login.args == ("my-cool-username", "my-cool-password")
61+
assert login.args == (
62+
"my-cool-username",
63+
"my-cool-password",
64+
) # .args available in py3.8+, this fails on py3.7
5765

5866
# and another, to send the message
5967
email = send_message.args[0]
@@ -67,6 +75,9 @@ def test_callback_occurs_on_train_end(self):
6775

6876
assert "model <neural-network> has completed its training!" in payload
6977

78+
@pytest.mark.skipif(
79+
sys.version_info < (3, 8), reason="requires python3.8 or higher"
80+
)
7081
def test_callback_occurs_on_train_end_while_both_message_and_subject_are_overridden(
7182
self,
7283
):
@@ -118,7 +129,10 @@ def test_callback_occurs_on_train_end_while_both_message_and_subject_are_overrid
118129
login, send_message = smtp_mock.method_calls
119130

120131
# one time to authenticate against the SMTP server
121-
assert login.args == ("my-cool-username", "my-cool-password")
132+
assert login.args == (
133+
"my-cool-username",
134+
"my-cool-password",
135+
) # .args available in py3.8+, this fails on py3.7
122136

123137
# and another, to send the message
124138
email = send_message.args[0]

0 commit comments

Comments
 (0)