820 python 3 only (#1454)

* Remove Python 2 specific code
* Require imports to have a proper isort-supported order
* Only test/lint on Python 3
* Bump most dependencies to latest supported version
This commit is contained in:
Kevin Chung
2020-05-30 02:43:49 -04:00
committed by GitHub
parent 72be918e06
commit 76e5ad08a8
45 changed files with 213 additions and 323 deletions

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import six
from unittest.mock import patch
from freezegun import freeze_time
from mock import patch
from CTFd.models import Users, db
from CTFd.utils import get_config, set_config
@@ -306,10 +306,7 @@ def test_user_can_confirm_email(mock_smtp):
assert "Need to resend the confirmation email?" in r.get_data(as_text=True)
# smtp send message function was called
if six.PY2:
mock_smtp.return_value.sendmail.assert_called()
else:
mock_smtp.return_value.send_message.assert_called()
mock_smtp.return_value.send_message.assert_called()
with client.session_transaction() as sess:
data = {"nonce": sess.get("nonce")}
@@ -336,10 +333,7 @@ def test_user_can_confirm_email(mock_smtp):
@patch("smtplib.SMTP")
def test_user_can_reset_password(mock_smtp):
"""Test that a user is capable of resetting their password"""
from email.mime.text import MIMEText
if six.PY3:
from email.message import EmailMessage
from email.message import EmailMessage
app = create_ctfd()
with app.app_context(), freeze_time("2012-01-14 03:21:34"):
@@ -377,11 +371,8 @@ def test_user_can_reset_password(mock_smtp):
)
ctf_name = get_config("ctf_name")
if six.PY2:
email_msg = MIMEText(msg)
else:
email_msg = EmailMessage()
email_msg.set_content(msg)
email_msg = EmailMessage()
email_msg.set_content(msg)
email_msg["Subject"] = "Password Reset Request from {ctf_name}".format(
ctf_name=ctf_name
@@ -390,15 +381,10 @@ def test_user_can_reset_password(mock_smtp):
email_msg["To"] = to_addr
# Make sure that the reset password email is sent
if six.PY2:
mock_smtp.return_value.sendmail.assert_called_with(
from_addr, [to_addr], email_msg.as_string()
)
else:
mock_smtp.return_value.send_message.assert_called()
assert str(mock_smtp.return_value.send_message.call_args[0][0]) == str(
email_msg
)
mock_smtp.return_value.send_message.assert_called()
assert str(mock_smtp.return_value.send_message.call_args[0][0]) == str(
email_msg
)
# Get user's original password
user = Users.query.filter_by(email="user@user.com").first()