Skip to content

Commit

Permalink
Fix for Python 3.6 test_mute_duration
Browse files Browse the repository at this point in the history
  • Loading branch information
LilSpazJoekp committed Feb 3, 2021
1 parent c246a56 commit 49ff934
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/integration/models/reddit/test_modmail.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from datetime import datetime
from unittest import mock

Expand Down Expand Up @@ -42,9 +43,19 @@ def test_mute_duration(self, _):
conversation.mute(7)
conversation = self.reddit.subreddit("all").modmail("g46rw")
assert conversation.user.mute_status["isMuted"]
diff = datetime.fromisoformat(
conversation.user.mute_status["endDate"]
) - datetime.fromisoformat(conversation.mod_actions[-1].date)
if sys.version_info >= (3, 7, 0):
diff = datetime.fromisoformat(
conversation.user.mute_status["endDate"]
) - datetime.fromisoformat(conversation.mod_actions[-1].date)
else:
end_date = "".join(
conversation.user.mute_status["endDate"].rsplit(":", 1)
)
start_date = "".join(conversation.mod_actions[-1].date.rsplit(":", 1))
date_format = "%Y-%m-%dT%H:%M:%S.%f%z"
diff = datetime.strptime(end_date, date_format) - datetime.strptime(
start_date, date_format
)
assert diff.days == 6 # 6 here because it is not 7 whole days

@mock.patch("time.sleep", return_value=None)
Expand Down

0 comments on commit 49ff934

Please sign in to comment.