TE-2689 Remove useless pylint suppressions part 4

This commit is contained in:
Jeremy Bowman
2018-08-20 12:02:26 -04:00
parent f022e98971
commit 3ff3eee2f2
45 changed files with 47 additions and 69 deletions

View File

@@ -167,7 +167,7 @@ class SAMLProviderDataAdmin(admin.ModelAdmin):
def get_readonly_fields(self, request, obj=None):
if obj: # editing an existing object
return [field.name for field in self.model._meta.get_fields()] # pylint: disable=protected-access
return [field.name for field in self.model._meta.get_fields()]
return self.readonly_fields

View File

@@ -1,4 +1,3 @@
# pylint: disable=no-member
"""
Tests for the Third Party Auth REST API
"""

View File

@@ -3,7 +3,6 @@
from third_party_auth.tests.specs import base
# pylint: disable=test-inherits-tests
class AzureADOauth2IntegrationTest(base.Oauth2IntegrationTest):
"""Integration tests for Azure Active Directory / Microsoft Account provider."""

View File

@@ -77,7 +77,7 @@ class GoogleOauth2IntegrationTest(base.Oauth2IntegrationTest):
response = self.client.get(response['Location'])
self.assertEqual(response.status_code, 200)
self.assertIn('action="/misc/my-custom-registration-form" method="post"', response.content)
data_decoded = base64.b64decode(response.context['data']) # pylint: disable=no-member
data_decoded = base64.b64decode(response.context['data'])
data_parsed = json.loads(data_decoded)
# The user's details get passed to the custom page as a base64 encoded query parameter:
self.assertEqual(data_parsed, {
@@ -95,7 +95,7 @@ class GoogleOauth2IntegrationTest(base.Oauth2IntegrationTest):
# Check the hash that is used to confirm the user's data in the GET parameter is correct
secret_key = settings.THIRD_PARTY_AUTH_CUSTOM_AUTH_FORMS['custom1']['secret_key']
hmac_expected = hmac.new(secret_key, msg=data_decoded, digestmod=hashlib.sha256).digest()
self.assertEqual(base64.b64decode(response.context['hmac']), hmac_expected) # pylint: disable=no-member
self.assertEqual(base64.b64decode(response.context['hmac']), hmac_expected)
# Now our custom registration form creates or logs in the user:
email, password = data_parsed['user_details']['email'], 'random_password'

View File

@@ -58,7 +58,6 @@ class Oauth2ProviderConfigAdminTest(testutil.TestCase):
# Edit the provider via the admin edit link
admin = OAuth2ProviderConfigAdmin(provider1, AdminSite())
# pylint: disable=protected-access
update_url = reverse('admin:{}_{}_add'.format(admin.model._meta.app_label, admin.model._meta.model_name))
update_url += "?source={}".format(provider1.pk)

View File

@@ -1,16 +1,11 @@
"""Unit tests for third_party_auth/pipeline.py."""
import random
import unittest
from third_party_auth import pipeline
from third_party_auth.tests import testutil
# Allow tests access to protected methods (or module-protected methods) under test.
# pylint: disable=protected-access
@unittest.skipUnless(testutil.AUTH_FEATURE_ENABLED, testutil.AUTH_FEATURES_KEY + ' not enabled')
class ProviderUserStateTestCase(testutil.TestCase):
"""Tests ProviderUserState behavior."""

View File

@@ -345,7 +345,6 @@ class UserDetailsForceSyncTestCase(testutil.TestCase, test.TestCase):
def setUp(self):
super(UserDetailsForceSyncTestCase, self).setUp()
# pylint: disable=attribute-defined-outside-init
self.user = UserFactory.create()
self.old_email = self.user.email
self.old_username = self.user.username

View File

@@ -59,7 +59,7 @@ class ThirdPartyAuthTestMixin(object):
# Django's FileSystemStorage will rename files if they already exist.
# This storage backend overwrites files instead, which makes it easier
# to make assertions about filenames.
icon_image_field = OAuth2ProviderConfig._meta.get_field('icon_image') # pylint: disable=protected-access
icon_image_field = OAuth2ProviderConfig._meta.get_field('icon_image')
patch = mock.patch.object(icon_image_field, 'storage', OverwriteStorage())
patch.start()
self.addCleanup(patch.stop)

View File

@@ -155,27 +155,27 @@ class CoursewarePage(CoursePage, CompletionOnViewMixin):
return int(tab_id.split('_')[1])
@property
def _active_sequence_tab(self): # pylint: disable=missing-docstring
def _active_sequence_tab(self):
return self.q(css='#sequence-list .nav-item.active')
@property
def is_next_button_enabled(self): # pylint: disable=missing-docstring
def is_next_button_enabled(self):
return not self.q(css='.sequence-nav > .sequence-nav-button.button-next.disabled').is_present()
@property
def is_previous_button_enabled(self): # pylint: disable=missing-docstring
def is_previous_button_enabled(self):
return not self.q(css='.sequence-nav > .sequence-nav-button.button-previous.disabled').is_present()
def click_next_button_on_top(self): # pylint: disable=missing-docstring
def click_next_button_on_top(self):
self._click_navigation_button('sequence-nav', 'button-next')
def click_next_button_on_bottom(self): # pylint: disable=missing-docstring
def click_next_button_on_bottom(self):
self._click_navigation_button('sequence-bottom', 'button-next')
def click_previous_button_on_top(self): # pylint: disable=missing-docstring
def click_previous_button_on_top(self):
self._click_navigation_button('sequence-nav', 'button-previous')
def click_previous_button_on_bottom(self): # pylint: disable=missing-docstring
def click_previous_button_on_bottom(self):
self._click_navigation_button('sequence-bottom', 'button-previous')
def _click_navigation_button(self, top_or_bottom_class, next_or_previous_class):

View File

@@ -1480,7 +1480,7 @@ class CertificatesPage(PageObject):
return self.get_selector('#btn-start-generating-certificates')
@property
def generate_certificates_disabled_button(self): # pylint: disable=invalid-name
def generate_certificates_disabled_button(self):
"""
Returns the disabled state of button
"""
@@ -1529,7 +1529,7 @@ class CertificatesPage(PageObject):
return self.get_selector('div.certificate-invalidation-container table tr:last-child td')
@property
def certificate_invalidation_message(self): # pylint: disable=invalid-name
def certificate_invalidation_message(self):
"""
Returns the message (error/success) in "Certificate Invalidation" section.
"""

View File

@@ -488,7 +488,6 @@ class XBlockWrapper(PageObject):
return self._validation_paragraph('error').present
@property
# pylint: disable=invalid-name
def has_validation_not_configured_warning(self):
""" Is a validation "not configured" message shown? """
return self._validation_paragraph('not-configured').present
@@ -508,7 +507,6 @@ class XBlockWrapper(PageObject):
return self.q(css=self._bounded_selector('{} .xblock-message-item.error'.format(self.VALIDATION_SELECTOR))).text
@property
# pylint: disable=invalid-name
def validation_not_configured_warning_text(self):
""" Get the text of the validation "not configured" message. """
return self._validation_paragraph('not-configured').text[0]

View File

@@ -38,7 +38,7 @@ class CourseOutlineItem(object):
# Check for the existence of a locator so that errors when navigating to the course outline page don't show up
# as errors in the repr method instead.
try:
return "{}(<browser>, {!r})".format(self.__class__.__name__, self.locator) # pylint: disable=no-member
return "{}(<browser>, {!r})".format(self.__class__.__name__, self.locator)
except AttributeError:
return "{}(<browser>)".format(self.__class__.__name__)
@@ -1179,7 +1179,7 @@ class SubsectionOutlineModal(CourseOutlineModal):
return self.find_css('input[name=content-visibility]:checked').first.attrs('value')[0]
@is_explicitly_locked.setter
def is_explicitly_locked(self, value): # pylint: disable=arguments-differ
def is_explicitly_locked(self, value):
"""
Override - sets visibility to staff_only if True, else 'visible'.

View File

@@ -43,8 +43,8 @@ class BaseDiscussionMixin(object):
"""
Set up multiple threads on the page by passing 'thread_count'.
"""
self.thread_ids = [] # pylint: disable=attribute-defined-outside-init
threads = [] # pylint: disable=attribute-defined-outside-init
self.thread_ids = []
threads = []
for i in range(thread_count):
thread_id = "test_thread_{}_{}".format(i, uuid4().hex)
thread_body = "Dummy long text body." * 50

View File

@@ -414,7 +414,7 @@ class DiscussionTabSingleThreadTest(BaseDiscussionTestCase, DiscussionResponsePa
Response(id="response1"),
[Comment(id="comment1")])
thread_fixture.push()
self.setup_thread_page(thread.get("id")) # pylint: disable=no-member
self.setup_thread_page(thread.get("id"))
# Verify that `Add a Post` is not visible on course tab nav.
self.assertFalse(self.tab_nav.has_new_post_button_visible_on_tab())

View File

@@ -29,7 +29,6 @@ class AccountSettingsTestMixin(EventsTestMixin, AcceptanceTest):
Visit the account settings page for the current user, and store the page instance
as self.account_settings_page.
"""
# pylint: disable=attribute-defined-outside-init
self.account_settings_page = AccountSettingsPage(self.browser)
self.account_settings_page.visit()
self.account_settings_page.wait_for_ajax()

View File

@@ -67,7 +67,7 @@ class BookmarksTestMixin(EventsTestMixin, UniqueCourseTest):
Arguments:
num_chapters: number of chapters to create
"""
self.course_fixture = CourseFixture( # pylint: disable=attribute-defined-outside-init
self.course_fixture = CourseFixture(
self.course_info['org'], self.course_info['number'],
self.course_info['run'], self.course_info['display_name']
)

View File

@@ -79,7 +79,7 @@ class LearnerProfileTestMixin(EventsTestMixin):
# Reset event tracking so that the tests only see events from
# loading the profile page.
self.start_time = datetime.now() # pylint: disable=attribute-defined-outside-init
self.start_time = datetime.now()
# Load the page
profile_page.visit()

View File

@@ -34,7 +34,7 @@ class StaffViewTest(UniqueCourseTest):
self.course_info['run'], self.course_info['display_name']
)
self.populate_course_fixture(self.course_fixture) # pylint: disable=no-member
self.populate_course_fixture(self.course_fixture)
self.course_fixture.install()

View File

@@ -42,7 +42,7 @@ class ProgressPageBaseTest(UniqueCourseTest):
def setUp(self):
super(ProgressPageBaseTest, self).setUp()
self.courseware_page = CoursewarePage(self.browser, self.course_id)
self.problem_page = ProblemPage(self.browser) # pylint: disable=attribute-defined-outside-init
self.problem_page = ProblemPage(self.browser)
self.progress_page = ProgressPage(self.browser, self.course_id)
self.logout_page = LogoutPage(self.browser)

View File

@@ -921,7 +921,6 @@ class TeamFormActions(TeamsTabBase):
def verify_and_navigate_to_edit_team_page(self):
"""Navigates to the edit team page and verifies."""
# pylint: disable=no-member
self.assertEqual(self.team_page.team_name, self.team['name'])
self.assertTrue(self.team_page.edit_team_button_present)
@@ -942,7 +941,6 @@ class TeamFormActions(TeamsTabBase):
def verify_team_info(self, name, description, location, language):
"""Verify the team information on team page."""
# pylint: disable=no-member
self.assertEqual(self.team_page.team_name, name)
self.assertEqual(self.team_page.team_description, description)
self.assertEqual(self.team_page.team_location, location)

View File

@@ -72,7 +72,7 @@ class SignUpAndSignInTest(UniqueCourseTest):
"""
shard = 21
def setUp(self): # pylint: disable=arguments-differ
def setUp(self):
super(SignUpAndSignInTest, self).setUp()
self.sign_up_page = SignupPage(self.browser)
self.login_page = LoginPage(self.browser)

View File

@@ -53,7 +53,7 @@ class VideoBaseTest(UniqueCourseTest):
Initialization of pages and course fixture for video tests
"""
super(VideoBaseTest, self).setUp()
self.longMessage = True # pylint: disable=invalid-name
self.longMessage = True
self.video = VideoPage(self.browser)
self.tab_nav = TabNavPage(self.browser)

View File

@@ -91,7 +91,7 @@ class MockSignalHandlerMixin(object):
mock_signal.connect(mock_handler)
yield
self.assertTrue(mock_handler.called)
mock_args, mock_kwargs = mock_handler.call_args # pylint: disable=unpacking-non-sequence
mock_args, mock_kwargs = mock_handler.call_args
if 'exclude_args' in kwargs:
for key in kwargs['exclude_args']:
self.assertIn(key, mock_kwargs)

View File

@@ -27,7 +27,7 @@ class FormatHtmlTest(unittest.TestCase):
(u"<a>нтмℓ-єѕ¢αρє∂</a>", u"&lt;a&gt;нтмℓ-єѕ¢αρє∂&lt;/a&gt;"),
)
def test_simple(self, (before, after)):
self.assertEqual(unicode(Text(_(before))), after) # pylint: disable=translation-of-non-string
self.assertEqual(unicode(Text(_(before))), after)
self.assertEqual(unicode(Text(before)), after)
def test_formatting(self):

View File

@@ -38,20 +38,20 @@ factory = APIRequestFactory() # pylint: disable=invalid-name
class MockView(APIView): # pylint: disable=missing-docstring
permission_classes = (IsAuthenticated,)
def get(self, request): # pylint: disable=unused-argument
def get(self, _request):
return HttpResponse({'a': 1, 'b': 2, 'c': 3})
def post(self, request): # pylint: disable=unused-argument
def post(self, _request):
return HttpResponse({'a': 1, 'b': 2, 'c': 3})
def put(self, request): # pylint: disable=unused-argument
def put(self, _request):
return HttpResponse({'a': 1, 'b': 2, 'c': 3})
# This is the a change we've made from the django-rest-framework-oauth version
# of these tests. We're subclassing our custom OAuth2AuthenticationAllowInactiveUser
# instead of OAuth2Authentication.
class OAuth2AuthenticationDebug(authentication.OAuth2AuthenticationAllowInactiveUser): # pylint: disable=missing-docstring
class OAuth2AuthenticationDebug(authentication.OAuth2AuthenticationAllowInactiveUser):
allow_query_params_token = True
@@ -164,7 +164,7 @@ class OAuth2Tests(TestCase):
self.assertEqual(response.status_code, status_code)
self.assertEqual(response_dict['error_code'], error_code)
def _create_authorization_header(self, token=None): # pylint: disable=missing-docstring
def _create_authorization_header(self, token=None):
if token is None:
token = self.access_token.token
return "Bearer {0}".format(token)

View File

@@ -151,7 +151,7 @@ def build_api_error(message, **kwargs):
"""
return {
'developer_message': message.format(**kwargs),
'user_message': _(message).format(**kwargs), # pylint: disable=translation-of-non-string
'user_message': _(message).format(**kwargs),
}

View File

@@ -15,7 +15,7 @@ class StudentModuleHistoryExtendedRouter(object):
Return True if ``model`` is courseware.StudentModuleHistoryExtended.
"""
return (
model._meta.app_label == 'coursewarehistoryextended' and # pylint: disable=protected-access
model._meta.app_label == 'coursewarehistoryextended' and
model.__name__ == 'StudentModuleHistoryExtended'
)

View File

@@ -91,7 +91,7 @@ def gating_enabled(default=None):
otherwise the result of the decorated function
"""
def wrap(f): # pylint: disable=missing-docstring
def function_wrapper(course, *args): # pylint: disable=missing-docstring
def function_wrapper(course, *args):
if not course.enable_subsection_gating:
return default
return f(course, *args)

View File

@@ -180,7 +180,7 @@ class TestGatingApi(ModuleStoreTestCase, MilestonesTestCaseMixin):
self.assertEqual(gating_api.get_gated_content(self.course, staff), [])
self.assertEqual(gating_api.get_gated_content(self.course, student), [unicode(self.seq2.location)])
milestones_api.add_user_milestone({'id': student.id}, milestone) # pylint: disable=no-member
milestones_api.add_user_milestone({'id': student.id}, milestone)
self.assertEqual(gating_api.get_gated_content(self.course, student), [])

View File

@@ -40,7 +40,7 @@ class TestJwtBuilder(mixins.AccessTokenMixin, TestCase):
"""
Verify that token construction succeeds if the UserProfile is missing.
"""
self.profile.delete() # pylint: disable=no-member
self.profile.delete()
scopes = ['profile']
token = JwtBuilder(self.user).build_token(scopes, self.expires_in)

View File

@@ -62,7 +62,7 @@ def wrap_xblock(
block,
view,
frag,
context, # pylint: disable=unused-argument
context,
usage_id_serializer,
request_token, # pylint: disable=redefined-outer-name
display_name_only=False,

View File

@@ -22,8 +22,6 @@ class TestCourseBookmarksTool(SharedModuleStoreTestCase):
"""
Set up a course to be used for testing.
"""
# setUpClassAndTestData() already calls setUpClass on SharedModuleStoreTestCase
# pylint: disable=super-method-not-called
with super(TestCourseBookmarksTool, cls).setUpClassAndTestData():
with cls.store.default_store(ModuleStoreEnum.Type.split):
cls.course = CourseFactory.create()

View File

@@ -25,5 +25,5 @@ def add_course_mode(course, upgrade_deadline_expired=False):
mode_slug=CourseMode.VERIFIED,
mode_display_name="Verified Certificate",
min_price=TEST_COURSE_PRICE,
_expiration_datetime=upgrade_exp_date, # pylint: disable=protected-access
_expiration_datetime=upgrade_exp_date,
).save()

View File

@@ -89,8 +89,6 @@ class CourseHomePageTestCase(SharedModuleStoreTestCase):
"""
Set up a course to be used for testing.
"""
# setUpClassAndTestData() already calls setUpClass on SharedModuleStoreTestCase
# pylint: disable=super-method-not-called
with super(CourseHomePageTestCase, cls).setUpClassAndTestData():
with cls.store.default_store(ModuleStoreEnum.Type.split):
cls.course = CourseFactory.create(

View File

@@ -565,7 +565,7 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
switches = waffle.waffle()
# pylint: disable=protected-access
switch_name = switches._namespaced_name(waffle.ENABLE_COMPLETION_TRACKING)
switch, _ = Switch.objects.get_or_create(name=switch_name) # pylint: disable=unpacking-non-sequence
switch, _ = Switch.objects.get_or_create(name=switch_name)
self.assertEqual(switch.created, view._completion_data_collection_start())

View File

@@ -82,8 +82,6 @@ class TestCourseUpdatesPage(SharedModuleStoreTestCase):
@classmethod
def setUpClass(cls):
"""Set up the simplest course possible."""
# setUpClassAndTestData() already calls setUpClass on SharedModuleStoreTestCase
# pylint: disable=super-method-not-called
with super(TestCourseUpdatesPage, cls).setUpClassAndTestData():
with cls.store.default_store(ModuleStoreEnum.Type.split):
cls.course = CourseFactory.create()

View File

@@ -146,7 +146,7 @@ class EnterpriseApiClient(object):
'course_id': course_id,
'consent_granted': consent_granted,
}
endpoint = getattr(self.client, 'enterprise-course-enrollment') # pylint: disable=literal-used-as-attribute
endpoint = getattr(self.client, 'enterprise-course-enrollment')
try:
endpoint.post(data=data)
except (HttpClientError, HttpServerError):

View File

@@ -12,4 +12,4 @@ class EnterpriseSupportConfig(AppConfig):
def ready(self):
# Import signals to activate signal handler for enterprise.
from . import signals # pylint: disable=unused-import, unused-variable
from . import signals # pylint: disable=unused-variable

View File

@@ -7,7 +7,7 @@ from django.db.models.signals import post_save
from django.contrib.auth.models import User
from enterprise.models import EnterpriseCustomerUser
from email_marketing.tasks import update_user # pylint: disable=import-error
from email_marketing.tasks import update_user
@receiver(post_save, sender=EnterpriseCustomerUser)

View File

@@ -264,7 +264,7 @@ class EnterpriseTestConsentRequired(SimpleTestCase):
while(response.status_code == 302 and 'grant_data_sharing_permissions' not in response.url):
response = client.get(response.url)
self.assertEqual(response.status_code, 302)
self.assertIn('grant_data_sharing_permissions', response.url) # pylint: disable=no-member
self.assertIn('grant_data_sharing_permissions', response.url)
# Ensure that when consent is not necessary, the user continues through to the requested page.
mock_consent_necessary.return_value = False
@@ -273,5 +273,5 @@ class EnterpriseTestConsentRequired(SimpleTestCase):
# If we were expecting a redirect, ensure it's not to the data sharing permission page
if status_code == 302:
self.assertNotIn('grant_data_sharing_permissions', response.url) # pylint: disable=no-member
self.assertNotIn('grant_data_sharing_permissions', response.url)
return response

View File

@@ -5,7 +5,7 @@ import datetime
import ddt
import mock
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
from lms.djangoapps.certificates.api import is_passing_status
from lms.envs.test import CREDENTIALS_PUBLIC_SERVICE_URL
from course_modes.models import CourseMode

View File

@@ -54,7 +54,6 @@ class TestDone(XBlockTestCase):
"""
resp = self.ajax('toggle_button', block, data)
self.assertEqual(resp.status_code, 200)
# pylint: disable=no-member
self.assertEqual(resp.data, {"state": desired_state})
# pylint: disable=unused-argument

View File

@@ -35,7 +35,7 @@ class InvalidTestName(Exception):
xblock_loaded = False # pylint: disable=invalid-name
for entrypoint in pkg_resources.iter_entry_points(group="xblock.test.v0"): # pylint: disable=no-member
for entrypoint in pkg_resources.iter_entry_points(group="xblock.test.v0"):
plugin = entrypoint.load()
classname = plugin.__name__
if classname in globals():

View File

@@ -199,7 +199,6 @@ class TestPaverServerTasks(PaverTestCase):
]
)
# pylint: disable=too-many-statements
def verify_server_task(self, task_name, options, contracts_default=False):
"""
Verify the output of a server task.

View File

@@ -2,6 +2,6 @@
set -e
export LOWER_PYLINT_THRESHOLD=1000
export UPPER_PYLINT_THRESHOLD=2975
export UPPER_PYLINT_THRESHOLD=2900
export ESLINT_THRESHOLD=5590
export STYLELINT_THRESHOLD=973