From 004d8563165abd6f89d4e41ac49ff6df314177a0 Mon Sep 17 00:00:00 2001 From: arbisoft Date: Thu, 11 Jul 2019 14:04:05 +0500 Subject: [PATCH] Fixing python-modernize issues. --- .../management/commands/tests/test_saml.py | 13 +++++++------ .../djangoapps/third_party_auth/tests/factories.py | 2 ++ .../third_party_auth/tests/test_decorators.py | 2 ++ .../third_party_auth/tests/test_middleware.py | 4 +++- .../third_party_auth/tests/test_pipeline.py | 2 ++ .../tests/test_pipeline_integration.py | 8 +++++--- .../third_party_auth/tests/test_provider.py | 2 ++ .../djangoapps/third_party_auth/tests/test_saml.py | 11 ++++++++--- 8 files changed, 31 insertions(+), 13 deletions(-) diff --git a/common/djangoapps/third_party_auth/management/commands/tests/test_saml.py b/common/djangoapps/third_party_auth/management/commands/tests/test_saml.py index b9c76f470d..c471277f88 100644 --- a/common/djangoapps/third_party_auth/management/commands/tests/test_saml.py +++ b/common/djangoapps/third_party_auth/management/commands/tests/test_saml.py @@ -2,16 +2,17 @@ Tests for `saml` management command, this command fetches saml metadata from providers and updates existing data accordingly. """ -import unittest -import os -import mock +from __future__ import absolute_import -from django.test import TestCase +import os +import unittest + +import mock +from django.conf import settings from django.core.management import call_command from django.core.management.base import CommandError -from django.conf import settings +from django.test import TestCase from django.utils.six import StringIO - from requests import exceptions from requests.models import Response diff --git a/common/djangoapps/third_party_auth/tests/factories.py b/common/djangoapps/third_party_auth/tests/factories.py index b0fafd25a6..f47cb48fc8 100644 --- a/common/djangoapps/third_party_auth/tests/factories.py +++ b/common/djangoapps/third_party_auth/tests/factories.py @@ -1,6 +1,8 @@ """ Provides factories for third_party_auth models. """ +from __future__ import absolute_import + from factory import SubFactory from factory.django import DjangoModelFactory diff --git a/common/djangoapps/third_party_auth/tests/test_decorators.py b/common/djangoapps/third_party_auth/tests/test_decorators.py index c069ac412d..c6a9962334 100644 --- a/common/djangoapps/third_party_auth/tests/test_decorators.py +++ b/common/djangoapps/third_party_auth/tests/test_decorators.py @@ -1,6 +1,8 @@ """ Tests for third_party_auth decorators. """ +from __future__ import absolute_import + import unittest import ddt diff --git a/common/djangoapps/third_party_auth/tests/test_middleware.py b/common/djangoapps/third_party_auth/tests/test_middleware.py index 88757b264a..8a3558beb5 100644 --- a/common/djangoapps/third_party_auth/tests/test_middleware.py +++ b/common/djangoapps/third_party_auth/tests/test_middleware.py @@ -1,6 +1,8 @@ """ Tests for third party auth middleware """ +from __future__ import absolute_import + import mock from django.contrib.messages.middleware import MessageMiddleware from django.http import HttpResponse @@ -8,9 +10,9 @@ from django.test.client import RequestFactory from requests.exceptions import HTTPError from openedx.core.djangolib.testing.utils import skip_unless_lms +from student.helpers import get_next_url_for_login_page from third_party_auth.middleware import ExceptionMiddleware from third_party_auth.tests.testutil import TestCase -from student.helpers import get_next_url_for_login_page class ThirdPartyAuthMiddlewareTestCase(TestCase): diff --git a/common/djangoapps/third_party_auth/tests/test_pipeline.py b/common/djangoapps/third_party_auth/tests/test_pipeline.py index b4f700275b..a3250a0aa6 100644 --- a/common/djangoapps/third_party_auth/tests/test_pipeline.py +++ b/common/djangoapps/third_party_auth/tests/test_pipeline.py @@ -1,5 +1,7 @@ """Unit tests for third_party_auth/pipeline.py.""" +from __future__ import absolute_import + import unittest from third_party_auth import pipeline diff --git a/common/djangoapps/third_party_auth/tests/test_pipeline_integration.py b/common/djangoapps/third_party_auth/tests/test_pipeline_integration.py index ff68e84aed..1486f110cc 100644 --- a/common/djangoapps/third_party_auth/tests/test_pipeline_integration.py +++ b/common/djangoapps/third_party_auth/tests/test_pipeline_integration.py @@ -1,20 +1,22 @@ """Integration tests for pipeline.py.""" -import unittest +from __future__ import absolute_import import datetime +import unittest + +import ddt import mock import pytz -import ddt from django import test from django.contrib.auth import models from django.core import mail from social_django import models as social_models +from lms.djangoapps.verify_student.models import SSOVerification from student.tests.factories import UserFactory from third_party_auth import pipeline, provider from third_party_auth.tests import testutil -from lms.djangoapps.verify_student.models import SSOVerification # Get Django User model by reference from python-social-auth. Not a type # constant, pylint. diff --git a/common/djangoapps/third_party_auth/tests/test_provider.py b/common/djangoapps/third_party_auth/tests/test_provider.py index 2507f04dd7..c9749b937f 100644 --- a/common/djangoapps/third_party_auth/tests/test_provider.py +++ b/common/djangoapps/third_party_auth/tests/test_provider.py @@ -1,5 +1,7 @@ """Unit tests for provider.py.""" +from __future__ import absolute_import + import unittest from django.contrib.sites.models import Site diff --git a/common/djangoapps/third_party_auth/tests/test_saml.py b/common/djangoapps/third_party_auth/tests/test_saml.py index fcf1d3d24c..c956f8fa20 100644 --- a/common/djangoapps/third_party_auth/tests/test_saml.py +++ b/common/djangoapps/third_party_auth/tests/test_saml.py @@ -2,12 +2,17 @@ Unit tests for third_party_auth SAML auth providers """ +from __future__ import absolute_import + import mock -from third_party_auth.tests.testutil import SAMLTestCase from third_party_auth.saml import EdXSAMLIdentityProvider, get_saml_idp_class -from third_party_auth.tests.data.saml_identity_provider_mock_data import mock_conf, mock_attributes,\ - expected_user_details +from third_party_auth.tests.data.saml_identity_provider_mock_data import ( + expected_user_details, + mock_attributes, + mock_conf +) +from third_party_auth.tests.testutil import SAMLTestCase class TestEdXSAMLIdentityProvider(SAMLTestCase):