Apply pylint-amnesty.
This commit is contained in:
Awais Qureshi
2021-02-01 19:27:15 +05:00
parent fdb50bcce8
commit 44576ce3f6
32 changed files with 154 additions and 154 deletions

View File

@@ -14,7 +14,7 @@ from lms.djangoapps.instructor_task.models import InstructorTask
from common.djangoapps.student.tests.factories import UserFactory as StudentUserFactory
class InstructorTaskFactory(DjangoModelFactory):
class InstructorTaskFactory(DjangoModelFactory): # lint-amnesty, pylint: disable=missing-class-docstring
class Meta(object):
model = InstructorTask

View File

@@ -95,7 +95,7 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase):
"""Tests API methods that involve the submission of module-based background tasks."""
def setUp(self):
super(InstructorTaskModuleSubmitTest, self).setUp()
super(InstructorTaskModuleSubmitTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.initialize_course()
self.student = UserFactory.create(username="student", email="student@edx.org")
@@ -189,12 +189,12 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase):
task_function(self.create_task_request(self.instructor), location, **params)
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) # lint-amnesty, pylint: disable=line-too-long
class InstructorTaskCourseSubmitTest(TestReportMixin, InstructorTaskCourseTestCase):
"""Tests API methods that involve the submission of course-based background tasks."""
def setUp(self):
super(InstructorTaskCourseSubmitTest, self).setUp()
super(InstructorTaskCourseSubmitTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.initialize_course()
self.student = UserFactory.create(username="student", email="student@edx.org")

View File

@@ -14,7 +14,7 @@ from uuid import uuid4
import six
import unicodecsv
from celery.states import FAILURE, SUCCESS
from django.contrib.auth.models import User
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.urls import reverse
from mock import Mock, patch
from opaque_keys.edx.keys import CourseKey
@@ -55,7 +55,7 @@ class InstructorTaskTestCase(CacheIsolationTestCase):
Tests API and view methods that involve the reporting of status for background tasks.
"""
def setUp(self):
super(InstructorTaskTestCase, self).setUp()
super(InstructorTaskTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.student = UserFactory.create(username="student", email="student@edx.org")
self.instructor = UserFactory.create(username="instructor", email="instructor@edx.org")
@@ -314,7 +314,7 @@ class TestReportMixin(object):
if os.path.exists(self.tmp_dir):
shutil.rmtree(self.tmp_dir)
super(TestReportMixin, self).setUp()
super(TestReportMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
# Ensure that working with the temp directories in tests is thread safe
# by creating a unique temporary directory for each testcase.
@@ -356,7 +356,7 @@ class TestReportMixin(object):
report_path = report_store.path_to(self.course.id, report_csv_filename)
with report_store.storage.open(report_path) as csv_file:
# Expand the dict reader generator so we don't lose it's content
csv_rows = [row for row in unicodecsv.DictReader(csv_file, encoding='utf-8-sig')]
csv_rows = [row for row in unicodecsv.DictReader(csv_file, encoding='utf-8-sig')] # lint-amnesty, pylint: disable=unnecessary-comprehension
if ignore_other_columns:
csv_rows = [

View File

@@ -15,7 +15,7 @@ from collections import namedtuple
import ddt
import six
from celery.states import FAILURE, SUCCESS
from django.contrib.auth.models import User
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.test.utils import override_settings
from django.urls import reverse
from mock import patch
@@ -61,7 +61,7 @@ class TestIntegrationTask(InstructorTaskModuleTestCase):
self.assertEqual(instructor_task.task_type, task_type)
task_input = json.loads(instructor_task.task_input)
self.assertNotIn('student', task_input)
self.assertEqual(task_input['problem_url'], text_type(InstructorTaskModuleTestCase.problem_location(problem_url_name)))
self.assertEqual(task_input['problem_url'], text_type(InstructorTaskModuleTestCase.problem_location(problem_url_name))) # lint-amnesty, pylint: disable=line-too-long
status = json.loads(instructor_task.task_output)
self.assertEqual(status['exception'], 'ZeroDivisionError')
self.assertEqual(status['message'], expected_message)
@@ -80,7 +80,7 @@ class TestRescoringTask(TestIntegrationTask):
"""
def setUp(self):
super(TestRescoringTask, self).setUp()
super(TestRescoringTask, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.initialize_course()
self.create_instructor('instructor')
@@ -305,7 +305,7 @@ class TestRescoringTask(TestIntegrationTask):
self.assertEqual(instructor_task.task_type, 'rescore_problem')
task_input = json.loads(instructor_task.task_input)
self.assertNotIn('student', task_input)
self.assertEqual(task_input['problem_url'], text_type(InstructorTaskModuleTestCase.problem_location(problem_url_name)))
self.assertEqual(task_input['problem_url'], text_type(InstructorTaskModuleTestCase.problem_location(problem_url_name))) # lint-amnesty, pylint: disable=line-too-long
status = json.loads(instructor_task.task_output)
self.assertEqual(status['attempted'], 1)
self.assertEqual(status['succeeded'], 0)
@@ -370,7 +370,7 @@ class TestRescoringTask(TestIntegrationTask):
InstructorTaskModuleTestCase.problem_location(problem_url_name)
)
descriptor.data = problem_xml
with self.module_store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, descriptor.location.course_key):
with self.module_store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, descriptor.location.course_key): # lint-amnesty, pylint: disable=line-too-long
self.module_store.update_item(descriptor, self.user.id)
self.module_store.publish(descriptor.location, self.user.id)
else:
@@ -444,7 +444,7 @@ class TestResetAttemptsTask(TestIntegrationTask):
userlist = ['u1', 'u2', 'u3', 'u4']
def setUp(self):
super(TestResetAttemptsTask, self).setUp()
super(TestResetAttemptsTask, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.initialize_course()
self.create_instructor('instructor')
for username in self.userlist:
@@ -513,7 +513,7 @@ class TestDeleteProblemTask(TestIntegrationTask):
userlist = ['u1', 'u2', 'u3', 'u4']
def setUp(self):
super(TestDeleteProblemTask, self).setUp()
super(TestDeleteProblemTask, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.initialize_course()
self.create_instructor('instructor')
@@ -598,7 +598,7 @@ class TestGradeReportConditionalContent(TestReportMixin, TestConditionalContent,
Arguments:
dicts: tuple of dicts
"""
return dict([item for d in dicts for item in d.items()])
return dict([item for d in dicts for item in d.items()]) # lint-amnesty, pylint: disable=consider-using-dict-comprehension
def user_partition_group(user):
"""Return a dict having single key with value equals to students group in partition"""

View File

@@ -41,21 +41,21 @@ class ReportStoreTestMixin(object):
"""
def setUp(self):
super(ReportStoreTestMixin, self).setUp()
super(ReportStoreTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course_id = CourseLocator(org="testx", course="coursex", run="runx")
def create_report_store(self):
"""
Subclasses should override this and return their report store.
"""
pass
pass # lint-amnesty, pylint: disable=unnecessary-pass
def test_links_for_order(self):
"""
Test that ReportStore.links_for() returns file download links
in reverse chronological order.
"""
report_store = self.create_report_store()
report_store = self.create_report_store() # lint-amnesty, pylint: disable=assignment-from-no-return
self.assertEqual(report_store.links_for(self.course_id), [])
report_store.store(self.course_id, 'old_file', StringIO())

View File

@@ -18,10 +18,10 @@ class TestSubtasks(InstructorTaskCourseTestCase):
"""Tests for subtasks."""
def setUp(self):
super(TestSubtasks, self).setUp()
super(TestSubtasks, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.initialize_course()
def _enroll_students_in_course(self, course_id, num_students):
def _enroll_students_in_course(self, course_id, num_students): # lint-amnesty, pylint: disable=unused-argument
"""Create and enroll some students in the course."""
for _ in range(num_students):

View File

@@ -7,7 +7,7 @@ paths actually work.
import json
from functools import partial
from functools import partial # lint-amnesty, pylint: disable=unused-import
from uuid import uuid4
import ddt
@@ -31,7 +31,7 @@ from lms.djangoapps.instructor_task.tasks import (
rescore_problem,
reset_problem_attempts
)
from lms.djangoapps.instructor_task.tasks_helper.misc import upload_ora2_data
from lms.djangoapps.instructor_task.tasks_helper.misc import upload_ora2_data # lint-amnesty, pylint: disable=unused-import
from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory
from lms.djangoapps.instructor_task.tests.test_base import InstructorTaskModuleTestCase
from xmodule.modulestore.exceptions import ItemNotFoundError
@@ -43,7 +43,7 @@ class TestTaskFailure(Exception):
"""
An example exception to indicate failure of a mocked task.
"""
pass
pass # lint-amnesty, pylint: disable=unnecessary-pass
class TestInstructorTasks(InstructorTaskModuleTestCase):
@@ -52,7 +52,7 @@ class TestInstructorTasks(InstructorTaskModuleTestCase):
"""
def setUp(self):
super(TestInstructorTasks, self).setUp()
super(TestInstructorTasks, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.initialize_course()
self.instructor = self.create_instructor('instructor')
self.location = self.problem_location(PROBLEM_URL_NAME)
@@ -94,7 +94,7 @@ class TestInstructorTasks(InstructorTaskModuleTestCase):
def _run_task_with_mock_celery(self, task_class, entry_id, task_id, expected_failure_message=None):
"""Submit a task and mock how celery provides a current_task."""
self.current_task = Mock()
self.current_task = Mock() # lint-amnesty, pylint: disable=attribute-defined-outside-init
self.current_task.request = Mock()
self.current_task.request.id = task_id
self.current_task.update_state = Mock()
@@ -335,7 +335,7 @@ class TestOverrideScoreInstructorTask(TestInstructorTasks):
Tests score override for a problem in a course, for all students succeeds.
"""
mock_instance = MagicMock()
getattr(mock_instance, 'override_problem_score').return_value = None
getattr(mock_instance, 'override_problem_score').return_value = None # lint-amnesty, pylint: disable=literal-used-as-attribute
num_students = 10
self._create_students_with_state(num_students)
@@ -428,7 +428,7 @@ class TestRescoreInstructorTask(TestInstructorTasks):
mock_instance = MagicMock()
del mock_instance.rescore_problem
del mock_instance.rescore
with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_module_for_descriptor_internal') as mock_get_module:
with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_module_for_descriptor_internal') as mock_get_module: # lint-amnesty, pylint: disable=line-too-long
mock_get_module.return_value = mock_instance
with self.assertRaises(UpdateProblemModuleStateError):
self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id)
@@ -451,7 +451,7 @@ class TestRescoreInstructorTask(TestInstructorTasks):
num_students = 1
self._create_students_with_state(num_students, input_state)
task_entry = self._create_input_entry()
with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_module_for_descriptor_internal', return_value=None):
with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_module_for_descriptor_internal', return_value=None): # lint-amnesty, pylint: disable=line-too-long
self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id)
self.assert_task_output(
@@ -469,7 +469,7 @@ class TestRescoreInstructorTask(TestInstructorTasks):
Tests rescores a problem in a course, for all students succeeds.
"""
mock_instance = MagicMock()
getattr(mock_instance, 'rescore').return_value = None
getattr(mock_instance, 'rescore').return_value = None # lint-amnesty, pylint: disable=literal-used-as-attribute
mock_instance.has_submitted_answer.return_value = True
del mock_instance.done # old CAPA code used to use this value so we delete it here to be sure

View File

@@ -15,14 +15,14 @@ import tempfile
from collections import OrderedDict
from contextlib import contextmanager, ExitStack
from datetime import datetime, timedelta
from io import BytesIO
from zipfile import ZipFile
from io import BytesIO # lint-amnesty, pylint: disable=unused-import
from zipfile import ZipFile # lint-amnesty, pylint: disable=unused-import
import ddt
import unicodecsv
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
from django.urls import reverse # lint-amnesty, pylint: disable=unused-import
from edx_django_utils.cache import RequestCache
from freezegun import freeze_time
from mock import ANY, MagicMock, Mock, patch
@@ -30,16 +30,16 @@ from pytz import UTC
from six import text_type
from six.moves import range, zip
from six.moves.urllib.parse import quote
from waffle.testutils import override_switch
from waffle.testutils import override_switch # lint-amnesty, pylint: disable=unused-import
import openedx.core.djangoapps.user_api.course_tag.api as course_tag_api
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.course_modes.tests.factories import CourseModeFactory
from common.djangoapps.course_modes.tests.factories import CourseModeFactory # lint-amnesty, pylint: disable=unused-import
from lms.djangoapps.courseware.models import StudentModule
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
from lms.djangoapps.certificates.tests.factories import CertificateWhitelistFactory, GeneratedCertificateFactory
from lms.djangoapps.courseware.tests.factories import InstructorFactory
from lms.djangoapps.courseware.tests.factories import InstructorFactory # lint-amnesty, pylint: disable=unused-import
from lms.djangoapps.grades.course_data import CourseData
from lms.djangoapps.grades.models import PersistentCourseGrade, PersistentSubsectionGradeOverride
from lms.djangoapps.grades.subsection_grade import CreateSubsectionGrade
@@ -76,7 +76,7 @@ from openedx.core.djangoapps.credit.tests.factories import CreditCourseFactory
from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme
from openedx.core.djangoapps.util.testing import ContentGroupTestCase, TestConditionalContent
from openedx.core.lib.teams_config import TeamsConfig
from common.djangoapps.student.models import ALLOWEDTOENROLL_TO_ENROLLED, CourseEnrollment, CourseEnrollmentAllowed, ManualEnrollmentAudit
from common.djangoapps.student.models import ALLOWEDTOENROLL_TO_ENROLLED, CourseEnrollment, CourseEnrollmentAllowed, ManualEnrollmentAudit # lint-amnesty, pylint: disable=line-too-long, unused-import
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
from lms.djangoapps.survey.models import SurveyAnswer, SurveyForm
from xmodule.modulestore import ModuleStoreEnum
@@ -121,7 +121,7 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
Tests that CSV grade report generation works.
"""
def setUp(self):
super(TestInstructorGradeReport, self).setUp()
super(TestInstructorGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create()
@ddt.data([u'student@example.com', u'ni\xf1o@example.com'])
@@ -445,7 +445,7 @@ class TestTeamGradeReport(InstructorGradeReportTestCase):
""" Test that teams appear correctly in the grade report when it is enabled for the course. """
def setUp(self):
super(TestTeamGradeReport, self).setUp()
super(TestTeamGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create(teams_configuration=_TEAMS_CONFIG)
self.student1 = UserFactory.create()
CourseEnrollment.enroll(self.student1, self.course.id)
@@ -485,7 +485,7 @@ class TestProblemResponsesReport(TestReportMixin, InstructorTaskModuleTestCase):
"""
def setUp(self):
super(TestProblemResponsesReport, self).setUp()
super(TestProblemResponsesReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.initialize_course()
self.instructor = self.create_instructor('instructor')
self.student = self.create_student('student')
@@ -811,7 +811,7 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
Test that the problem CSV generation works.
"""
def setUp(self):
super(TestProblemGradeReport, self).setUp()
super(TestProblemGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.initialize_course()
# Add unicode data to CSV even though unicode usernames aren't
# technically possible in openedx.
@@ -959,7 +959,7 @@ class TestProblemReportSplitTestContent(TestReportMixin, TestConditionalContent,
OPTION_2 = 'Option 2'
def setUp(self):
super(TestProblemReportSplitTestContent, self).setUp()
super(TestProblemReportSplitTestContent, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.problem_a_url = u'problem_a_url'
self.problem_b_url = u'problem_b_url'
self.define_option_problem(self.problem_a_url, parent=self.vertical_a)
@@ -1088,7 +1088,7 @@ class TestProblemReportCohortedContent(TestReportMixin, ContentGroupTestCase, In
Test the problem report on a course that has cohorted content.
"""
def setUp(self):
super(TestProblemReportCohortedContent, self).setUp()
super(TestProblemReportCohortedContent, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
# construct cohorted problems to work on.
self.add_course_content()
vertical = ItemFactory.create(
@@ -1184,7 +1184,7 @@ class TestCourseSurveyReport(TestReportMixin, InstructorTaskCourseTestCase):
Tests that Course Survey report generation works.
"""
def setUp(self):
super(TestCourseSurveyReport, self).setUp()
super(TestCourseSurveyReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create()
self.question1 = "question1"
@@ -1279,7 +1279,7 @@ class TestStudentReport(TestReportMixin, InstructorTaskCourseTestCase):
Tests that CSV student profile report generation works.
"""
def setUp(self):
super(TestStudentReport, self).setUp()
super(TestStudentReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create()
def test_success(self):
@@ -1323,7 +1323,7 @@ class TestTeamStudentReport(TestReportMixin, InstructorTaskCourseTestCase):
"Test the student report when including teams information. "
def setUp(self):
super(TestTeamStudentReport, self).setUp()
super(TestTeamStudentReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create(teams_configuration=_TEAMS_CONFIG)
self.student1 = UserFactory.create()
CourseEnrollment.enroll(self.student1, self.course.id)
@@ -1393,7 +1393,7 @@ class TestListMayEnroll(TestReportMixin, InstructorTaskCourseTestCase):
)
def setUp(self):
super(TestListMayEnroll, self).setUp()
super(TestListMayEnroll, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create()
def test_success(self):
@@ -1431,7 +1431,7 @@ class MockDefaultStorage(object):
def open(self, file_name):
"""Mock out DefaultStorage.open with standard python open"""
return open(file_name) # pylint: disable=open-builtin
return open(file_name) # lint-amnesty, pylint: disable=bad-option-value, open-builtin
@patch('lms.djangoapps.instructor_task.tasks_helper.misc.DefaultStorage', new=MockDefaultStorage)
@@ -1440,7 +1440,7 @@ class TestCohortStudents(TestReportMixin, InstructorTaskCourseTestCase):
Tests that bulk student cohorting works.
"""
def setUp(self):
super(TestCohortStudents, self).setUp()
super(TestCohortStudents, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create()
self.cohort_1 = CohortFactory(course_id=self.course.id, name='Cohort 1')
@@ -1699,7 +1699,7 @@ class TestGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
Test that grade report has correct grade values.
"""
def setUp(self):
super(TestGradeReport, self).setUp()
super(TestGradeReport, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.create_course()
self.student = self.create_student(u'üser_1')
@@ -1858,7 +1858,7 @@ class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTas
Test that grade report has correct user enrollment, verification, and certificate information.
"""
def setUp(self):
super(TestGradeReportEnrollmentAndCertificateInfo, self).setUp()
super(TestGradeReportEnrollmentAndCertificateInfo, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
today = datetime.now(UTC)
course_factory_kwargs = {
@@ -2010,7 +2010,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache']
def setUp(self):
super(TestCertificateGeneration, self).setUp()
super(TestCertificateGeneration, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.initialize_course()
def test_certificate_generation_for_students(self):
@@ -2569,13 +2569,13 @@ class TestInstructorOra2Report(SharedModuleStoreTestCase):
cls.course = CourseFactory.create()
def setUp(self):
super(TestInstructorOra2Report, self).setUp()
super(TestInstructorOra2Report, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.current_task = Mock()
self.current_task.update_state = Mock()
def tearDown(self):
super(TestInstructorOra2Report, self).tearDown()
super(TestInstructorOra2Report, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments
if os.path.exists(settings.GRADES_DOWNLOAD['ROOT_PATH']):
shutil.rmtree(settings.GRADES_DOWNLOAD['ROOT_PATH'])