From cf9308144d762a567a59bc223d262186928e3183 Mon Sep 17 00:00:00 2001 From: stv Date: Sat, 8 Nov 2014 17:18:52 -0800 Subject: [PATCH] Fix PEP8: E302 expected 2 blank lines, found 1 --- .../contentstore/management/commands/delete_course.py | 1 + .../contentstore/management/commands/populate_creators.py | 2 ++ cms/djangoapps/contentstore/tests/test_transcripts_utils.py | 1 + cms/djangoapps/contentstore/tests/test_utils.py | 1 + cms/djangoapps/contentstore/views/checklist.py | 1 + cms/djangoapps/contentstore/views/course.py | 1 + cms/djangoapps/contentstore/views/tabs.py | 1 + cms/djangoapps/models/settings/course_details.py | 1 + common/djangoapps/contentserver/middleware.py | 1 + common/djangoapps/course_groups/cohorts.py | 1 + common/djangoapps/course_groups/tests/test_views.py | 1 + common/djangoapps/django_comment_common/tests.py | 1 + common/djangoapps/edxmako/paths.py | 1 + common/djangoapps/edxmako/shortcuts.py | 2 ++ common/djangoapps/edxmako/tests.py | 1 + common/djangoapps/embargo/tests/test_middleware.py | 1 + common/djangoapps/external_auth/tests/test_ssl.py | 1 + common/djangoapps/heartbeat/tests/test_heartbeat.py | 1 + .../microsite_configuration/templatetags/microsite.py | 1 + common/djangoapps/monitoring/signals.py | 1 + common/djangoapps/request_cache/middleware.py | 1 + common/djangoapps/student/middleware.py | 1 + common/djangoapps/student/models.py | 4 ++++ common/djangoapps/student/roles.py | 1 + common/djangoapps/student/tests/test_auto_auth.py | 1 + common/djangoapps/student/tests/test_microsite.py | 3 +++ common/djangoapps/student/tests/test_password_policy.py | 1 + common/djangoapps/terrain/stubs/comments.py | 1 + common/djangoapps/terrain/stubs/lti.py | 1 + common/djangoapps/terrain/stubs/tests/test_lti_stub.py | 1 + common/djangoapps/terrain/stubs/video_source.py | 1 + common/djangoapps/user_api/tests/factories.py | 1 + common/djangoapps/util/bad_request_rate_limiter.py | 1 + common/djangoapps/util/string_utils.py | 1 + common/djangoapps/util/tests/test_string_utils.py | 1 + common/lib/calc/calc/tests/test_calc.py | 1 + common/lib/capa/capa/registry.py | 1 + common/lib/capa/capa/safe_exec/lazymod.py | 1 + common/lib/capa/capa/tests/test_input_templates.py | 2 ++ common/lib/django_startup.py | 1 + common/lib/symmath/symmath/test_symmath_check.py | 1 + common/lib/tempdir.py | 2 ++ common/lib/xmodule/xmodule/annotator_mixin.py | 1 + common/lib/xmodule/xmodule/course_module.py | 2 ++ common/lib/xmodule/xmodule/lti_module.py | 1 + common/lib/xmodule/xmodule/modulestore/split_mongo/split.py | 1 + .../xmodule/xmodule/modulestore/tests/persistent_factories.py | 1 + .../xmodule/modulestore/tests/test_modulestore_settings.py | 1 + common/lib/xmodule/xmodule/modulestore/xml_importer.py | 1 + .../open_ended_grading_classes/controller_query_service.py | 1 + common/lib/xmodule/xmodule/split_test_module.py | 1 + common/lib/xmodule/xmodule/tabs.py | 1 + common/lib/xmodule/xmodule/tests/rendering/core.py | 1 + common/lib/xmodule/xmodule/tests/test_bulk_assertions.py | 1 + common/lib/xmodule/xmodule/tests/test_capa_module.py | 1 + common/lib/xmodule/xmodule/tests/test_content.py | 1 + common/lib/xmodule/xmodule/tests/test_utils_django.py | 1 + common/lib/xmodule/xmodule/timeinfo.py | 1 + common/lib/xmodule/xmodule/video_module/transcripts_utils.py | 3 +++ common/test/acceptance/fixtures/discussion.py | 1 + common/test/acceptance/pages/studio/overview.py | 2 ++ common/test/acceptance/performance/test_studio_performance.py | 1 + common/test/data/uploads/python_lib_zip/number_helpers.py | 1 + docs/en_us/developers/source/conf.py | 1 + docs/en_us/platform_api/source/conf.py | 1 + docs/shared/conf.py | 1 + lms/djangoapps/courseware/courses.py | 1 + lms/djangoapps/courseware/features/events.py | 1 + lms/djangoapps/courseware/features/gst.py | 1 + lms/djangoapps/courseware/grades.py | 1 + lms/djangoapps/courseware/middleware.py | 1 + lms/djangoapps/courseware/module_render.py | 1 + lms/djangoapps/courseware/tests/test_access.py | 1 + lms/djangoapps/courseware/tests/test_microsites.py | 1 + lms/djangoapps/courseware/views.py | 1 + lms/djangoapps/dashboard/git_import.py | 1 + .../dashboard/management/commands/git_add_course.py | 1 + lms/djangoapps/django_comment_client/forum/tests.py | 1 + lms/djangoapps/django_comment_client/tests/group_id.py | 1 + lms/djangoapps/django_comment_client/tests/unicode.py | 1 + lms/djangoapps/django_comment_client/tests/utils.py | 1 + .../instructor/management/commands/openended_post.py | 1 + lms/djangoapps/instructor/offline_gradecalc.py | 1 + lms/djangoapps/instructor/views/legacy.py | 1 + lms/djangoapps/instructor_task/admin.py | 1 + lms/djangoapps/notification_prefs/views.py | 1 + lms/djangoapps/open_ended_grading/staff_grading_service.py | 1 + lms/djangoapps/shoppingcart/exceptions.py | 1 + lms/djangoapps/shoppingcart/processors/exceptions.py | 1 + lms/djangoapps/shoppingcart/tests/test_models.py | 1 + lms/djangoapps/shoppingcart/views.py | 1 + lms/djangoapps/staticbook/views.py | 1 + lms/djangoapps/verify_student/tests/test_ssencrypt.py | 2 ++ manage.py | 1 + pavelib/acceptance_test.py | 1 + pavelib/i18n.py | 1 + pavelib/paver_tests/test_paver_quality.py | 1 + pavelib/quality.py | 4 ++++ pavelib/utils/envs.py | 1 + pavelib/utils/test/utils.py | 1 + scripts/run_watch_data.py | 1 + scripts/runone.py | 2 ++ 102 files changed, 120 insertions(+) diff --git a/cms/djangoapps/contentstore/management/commands/delete_course.py b/cms/djangoapps/contentstore/management/commands/delete_course.py index 6f77c8a048..2ae3318a72 100644 --- a/cms/djangoapps/contentstore/management/commands/delete_course.py +++ b/cms/djangoapps/contentstore/management/commands/delete_course.py @@ -9,6 +9,7 @@ from opaque_keys import InvalidKeyError from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore import ModuleStoreEnum + class Command(BaseCommand): help = '''Delete a MongoDB backed course''' diff --git a/cms/djangoapps/contentstore/management/commands/populate_creators.py b/cms/djangoapps/contentstore/management/commands/populate_creators.py index 900d1960cc..f56b3a635e 100644 --- a/cms/djangoapps/contentstore/management/commands/populate_creators.py +++ b/cms/djangoapps/contentstore/management/commands/populate_creators.py @@ -11,6 +11,8 @@ from django.db.utils import IntegrityError from student.roles import CourseInstructorRole, CourseStaffRole #------------ to run: ./manage.py cms populate_creators --settings=dev + + class Command(BaseCommand): """ Script for granting existing course instructors course creator privileges. diff --git a/cms/djangoapps/contentstore/tests/test_transcripts_utils.py b/cms/djangoapps/contentstore/tests/test_transcripts_utils.py index de7762d108..858f07a8b3 100644 --- a/cms/djangoapps/contentstore/tests/test_transcripts_utils.py +++ b/cms/djangoapps/contentstore/tests/test_transcripts_utils.py @@ -472,6 +472,7 @@ class TestYoutubeTranscripts(unittest.TestCase): self.assertEqual(transcripts, expected_transcripts) mock_get.assert_called_with('http://video.google.com/timedtext', params={'lang': 'en', 'v': 'good_youtube_id'}) + class TestTranscript(unittest.TestCase): """ Tests for Transcript class e.g. different transcript conversions. diff --git a/cms/djangoapps/contentstore/tests/test_utils.py b/cms/djangoapps/contentstore/tests/test_utils.py index 5d3e3e2c18..8698feb6d9 100644 --- a/cms/djangoapps/contentstore/tests/test_utils.py +++ b/cms/djangoapps/contentstore/tests/test_utils.py @@ -86,6 +86,7 @@ class LMSLinksTestCase(TestCase): link = utils.get_lms_link_for_item(location) self.assertEquals(link, "//localhost:8000/courses/mitX/101/test/jump_to/i4x://mitX/101/course/test") + class ExtraPanelTabTestCase(TestCase): """ Tests adding and removing extra course tabs. """ diff --git a/cms/djangoapps/contentstore/views/checklist.py b/cms/djangoapps/contentstore/views/checklist.py index 1b12e93aa3..0d58ee8a36 100644 --- a/cms/djangoapps/contentstore/views/checklist.py +++ b/cms/djangoapps/contentstore/views/checklist.py @@ -124,6 +124,7 @@ def expand_checklist_action_url(course_module, checklist): return expanded_checklist + def localize_checklist_text(checklist): """ Localize texts for a given checklist and returns the modified version. diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 77f6c95b58..5d5529aaf3 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -261,6 +261,7 @@ def course_rerun_handler(request, course_key_string): 'allow_unicode_course_id': settings.FEATURES.get('ALLOW_UNICODE_COURSE_ID', False) }) + def _course_outline_json(request, course_module): """ Returns a JSON representation of the course module and recursively all of its children. diff --git a/cms/djangoapps/contentstore/views/tabs.py b/cms/djangoapps/contentstore/views/tabs.py index e251e3dca8..bc4636a030 100644 --- a/cms/djangoapps/contentstore/views/tabs.py +++ b/cms/djangoapps/contentstore/views/tabs.py @@ -20,6 +20,7 @@ from ..utils import get_lms_link_for_item __all__ = ['tabs_handler'] + @expect_json @login_required @ensure_csrf_cookie diff --git a/cms/djangoapps/models/settings/course_details.py b/cms/djangoapps/models/settings/course_details.py index 6c61cd8419..e8080846a8 100644 --- a/cms/djangoapps/models/settings/course_details.py +++ b/cms/djangoapps/models/settings/course_details.py @@ -11,6 +11,7 @@ from models.settings import course_grading from xmodule.fields import Date from xmodule.modulestore.django import modulestore + class CourseDetails(object): def __init__(self, org, course_id, run): # still need these for now b/c the client's screen shows these 3 fields diff --git a/common/djangoapps/contentserver/middleware.py b/common/djangoapps/contentserver/middleware.py index 4ece37e656..d84e48ad1a 100644 --- a/common/djangoapps/contentserver/middleware.py +++ b/common/djangoapps/contentserver/middleware.py @@ -22,6 +22,7 @@ from xmodule.exceptions import NotFoundError log = logging.getLogger(__name__) + class StaticContentServer(object): def process_request(self, request): # look to see if the request is prefixed with an asset prefix tag diff --git a/common/djangoapps/course_groups/cohorts.py b/common/djangoapps/course_groups/cohorts.py index f691ef5191..37c0abf959 100644 --- a/common/djangoapps/course_groups/cohorts.py +++ b/common/djangoapps/course_groups/cohorts.py @@ -322,6 +322,7 @@ def add_cohort(course_key, name): ) return cohort + def add_user_to_cohort(cohort, username_or_email): """ Look up the given user, and if successful, add them to the specified cohort. diff --git a/common/djangoapps/course_groups/tests/test_views.py b/common/djangoapps/course_groups/tests/test_views.py index 819190237f..78fe1b623b 100644 --- a/common/djangoapps/course_groups/tests/test_views.py +++ b/common/djangoapps/course_groups/tests/test_views.py @@ -209,6 +209,7 @@ class ListCohortsTestCase(CohortViewsTestCase): actual_cohorts, ) + class AddCohortTestCase(CohortViewsTestCase): """ Tests the `add_cohort` view. diff --git a/common/djangoapps/django_comment_common/tests.py b/common/djangoapps/django_comment_common/tests.py index 158f8836c9..a57aa1f4df 100644 --- a/common/djangoapps/django_comment_common/tests.py +++ b/common/djangoapps/django_comment_common/tests.py @@ -4,6 +4,7 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey from django_comment_common.models import Role from student.models import CourseEnrollment, User + class RoleAssignmentTest(TestCase): """ Basic checks to make sure our Roles get assigned and unassigned as students diff --git a/common/djangoapps/edxmako/paths.py b/common/djangoapps/edxmako/paths.py index 518f8a530b..d14773954d 100644 --- a/common/djangoapps/edxmako/paths.py +++ b/common/djangoapps/edxmako/paths.py @@ -32,6 +32,7 @@ def clear_lookups(namespace): if namespace in LOOKUP: del LOOKUP[namespace] + def add_lookup(namespace, directory, package=None, prepend=False): """ Adds a new mako template lookup directory to the given namespace. diff --git a/common/djangoapps/edxmako/shortcuts.py b/common/djangoapps/edxmako/shortcuts.py index c17337c9c3..1e2566e184 100644 --- a/common/djangoapps/edxmako/shortcuts.py +++ b/common/djangoapps/edxmako/shortcuts.py @@ -76,6 +76,7 @@ def marketing_link_context_processor(request): ] ) + def open_source_footer_context_processor(request): """ Checks the site name to determine whether to use the edX.org footer or the Open Source Footer. @@ -97,6 +98,7 @@ def microsite_footer_context_processor(request): ] ) + def render_to_string(template_name, dictionary, context=None, namespace='main'): # see if there is an override template defined in the microsite diff --git a/common/djangoapps/edxmako/tests.py b/common/djangoapps/edxmako/tests.py index 40da9b63b8..318af76cb8 100644 --- a/common/djangoapps/edxmako/tests.py +++ b/common/djangoapps/edxmako/tests.py @@ -19,6 +19,7 @@ from edxmako.shortcuts import ( from student.tests.factories import UserFactory from util.testing import UrlResetMixin + @ddt.ddt class ShortcutsTests(UrlResetMixin, TestCase): """ diff --git a/common/djangoapps/embargo/tests/test_middleware.py b/common/djangoapps/embargo/tests/test_middleware.py index 48fe895f9c..a02f4d31b8 100644 --- a/common/djangoapps/embargo/tests/test_middleware.py +++ b/common/djangoapps/embargo/tests/test_middleware.py @@ -28,6 +28,7 @@ from embargo.models import EmbargoedCourse, EmbargoedState, IPFilter # that disables the XML modulestore. MODULESTORE_CONFIG = mixed_store_config(settings.COMMON_TEST_DATA_ROOT, {}, include_xml=False) + @ddt.ddt @override_settings(MODULESTORE=MODULESTORE_CONFIG) @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') diff --git a/common/djangoapps/external_auth/tests/test_ssl.py b/common/djangoapps/external_auth/tests/test_ssl.py index 2ffcee8d51..a81168d98e 100644 --- a/common/djangoapps/external_auth/tests/test_ssl.py +++ b/common/djangoapps/external_auth/tests/test_ssl.py @@ -37,6 +37,7 @@ FEATURES_WITHOUT_SSL_AUTH['AUTH_USE_CERTIFICATES'] = False TEST_DATA_MIXED_MODULESTORE = mixed_store_config(settings.COMMON_TEST_DATA_ROOT, {}) + @override_settings(FEATURES=FEATURES_WITH_SSL_AUTH) class SSLClientTest(ModuleStoreTestCase): """ diff --git a/common/djangoapps/heartbeat/tests/test_heartbeat.py b/common/djangoapps/heartbeat/tests/test_heartbeat.py index 5ac580fb2c..7addee256f 100644 --- a/common/djangoapps/heartbeat/tests/test_heartbeat.py +++ b/common/djangoapps/heartbeat/tests/test_heartbeat.py @@ -8,6 +8,7 @@ from django.db.utils import DatabaseError import mock from django.test.testcases import TestCase + class HeartbeatTestCase(TestCase): """ Test the heartbeat diff --git a/common/djangoapps/microsite_configuration/templatetags/microsite.py b/common/djangoapps/microsite_configuration/templatetags/microsite.py index 46731ceec2..1aea3c4944 100644 --- a/common/djangoapps/microsite_configuration/templatetags/microsite.py +++ b/common/djangoapps/microsite_configuration/templatetags/microsite.py @@ -23,6 +23,7 @@ def page_title_breadcrumbs(*crumbs, **kwargs): else: return platform_name() + @register.simple_tag(name="page_title_breadcrumbs", takes_context=True) def page_title_breadcrumbs_tag(context, *crumbs): """ diff --git a/common/djangoapps/monitoring/signals.py b/common/djangoapps/monitoring/signals.py index 89cf7cc94b..f636e7ae51 100644 --- a/common/djangoapps/monitoring/signals.py +++ b/common/djangoapps/monitoring/signals.py @@ -78,6 +78,7 @@ def post_save_metrics(sender, **kwargs): tags = _database_tags(action, sender, kwargs) dog_stats_api.increment('edxapp.db.model', tags=tags) + @receiver(post_delete, dispatch_uid='edxapp.monitoring.post_delete_metrics') def post_delete_metrics(sender, **kwargs): """ diff --git a/common/djangoapps/request_cache/middleware.py b/common/djangoapps/request_cache/middleware.py index 6640d1a38a..4b5ce114b0 100644 --- a/common/djangoapps/request_cache/middleware.py +++ b/common/djangoapps/request_cache/middleware.py @@ -3,6 +3,7 @@ import threading _request_cache_threadlocal = threading.local() _request_cache_threadlocal.data = {} + class RequestCache(object): @classmethod def get_request_cache(cls): diff --git a/common/djangoapps/student/middleware.py b/common/djangoapps/student/middleware.py index b4f6ad0686..ccffbb1659 100644 --- a/common/djangoapps/student/middleware.py +++ b/common/djangoapps/student/middleware.py @@ -7,6 +7,7 @@ from django.utils.translation import ugettext as _ from django.conf import settings from student.models import UserStanding + class UserStandingMiddleware(object): """ Checks a user's standing on request. Returns a 403 if the user's diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index dda87a80e5..09967cf346 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -665,15 +665,19 @@ class LoginFailures(models.Model): class CourseEnrollmentException(Exception): pass + class NonExistentCourseError(CourseEnrollmentException): pass + class EnrollmentClosedError(CourseEnrollmentException): pass + class CourseFullError(CourseEnrollmentException): pass + class AlreadyEnrolledError(CourseEnrollmentException): pass diff --git a/common/djangoapps/student/roles.py b/common/djangoapps/student/roles.py index 8fb38b5d14..5165966acb 100644 --- a/common/djangoapps/student/roles.py +++ b/common/djangoapps/student/roles.py @@ -210,6 +210,7 @@ class CourseFinanceAdminRole(CourseRole): def __init__(self, *args, **kwargs): super(CourseFinanceAdminRole, self).__init__(self.ROLE, *args, **kwargs) + class CourseBetaTesterRole(CourseRole): """A course Beta Tester""" ROLE = 'beta_testers' diff --git a/common/djangoapps/student/tests/test_auto_auth.py b/common/djangoapps/student/tests/test_auto_auth.py index 884729a84a..f6123d89c3 100644 --- a/common/djangoapps/student/tests/test_auto_auth.py +++ b/common/djangoapps/student/tests/test_auto_auth.py @@ -11,6 +11,7 @@ from opaque_keys.edx.locator import CourseLocator from mock import patch import ddt + @ddt.ddt class AutoAuthEnabledTestCase(UrlResetMixin, TestCase): """ diff --git a/common/djangoapps/student/tests/test_microsite.py b/common/djangoapps/student/tests/test_microsite.py index 93fa87f8d4..4574c429a8 100644 --- a/common/djangoapps/student/tests/test_microsite.py +++ b/common/djangoapps/student/tests/test_microsite.py @@ -25,6 +25,7 @@ FAKE_MICROSITE = { ] } + def fake_site_name(name, default=None): # pylint: disable=W0613 """ create a fake microsite site name @@ -34,12 +35,14 @@ def fake_site_name(name, default=None): # pylint: disable=W0613 else: return default + def fake_microsite_get_value(name, default=None): # pylint: disable=W0613 """ create a fake microsite site name """ return FAKE_MICROSITE.get(name, default) + class TestMicrosite(TestCase): """Test for Account Creation from a white labeled Micro-Sites""" def setUp(self): diff --git a/common/djangoapps/student/tests/test_password_policy.py b/common/djangoapps/student/tests/test_password_policy.py index 68f776e775..75ad3ce3ac 100644 --- a/common/djangoapps/student/tests/test_password_policy.py +++ b/common/djangoapps/student/tests/test_password_policy.py @@ -15,6 +15,7 @@ from edxmako.tests import mako_middleware_process_request from external_auth.models import ExternalAuthMap from student.views import create_account + @patch.dict("django.conf.settings.FEATURES", {'ENFORCE_PASSWORD_POLICY': True}) class TestPasswordPolicy(TestCase): """ diff --git a/common/djangoapps/terrain/stubs/comments.py b/common/djangoapps/terrain/stubs/comments.py index af4648fa3f..9d8e247a72 100644 --- a/common/djangoapps/terrain/stubs/comments.py +++ b/common/djangoapps/terrain/stubs/comments.py @@ -6,6 +6,7 @@ import re import urlparse from .http import StubHttpRequestHandler, StubHttpService + class StubCommentsServiceHandler(StubHttpRequestHandler): @property diff --git a/common/djangoapps/terrain/stubs/lti.py b/common/djangoapps/terrain/stubs/lti.py index 3bea875b38..b3dbcbafd5 100644 --- a/common/djangoapps/terrain/stubs/lti.py +++ b/common/djangoapps/terrain/stubs/lti.py @@ -21,6 +21,7 @@ import mock import requests from http import StubHttpRequestHandler, StubHttpService + class StubLtiHandler(StubHttpRequestHandler): """ A handler for LTI POST and GET requests. diff --git a/common/djangoapps/terrain/stubs/tests/test_lti_stub.py b/common/djangoapps/terrain/stubs/tests/test_lti_stub.py index 0ea2e2dcd6..34f2445ac2 100644 --- a/common/djangoapps/terrain/stubs/tests/test_lti_stub.py +++ b/common/djangoapps/terrain/stubs/tests/test_lti_stub.py @@ -7,6 +7,7 @@ import urllib2 import requests from terrain.stubs.lti import StubLtiService + class StubLtiServiceTest(unittest.TestCase): """ A stub of the LTI provider that listens on a local diff --git a/common/djangoapps/terrain/stubs/video_source.py b/common/djangoapps/terrain/stubs/video_source.py index 460b2f7560..fa48834546 100644 --- a/common/djangoapps/terrain/stubs/video_source.py +++ b/common/djangoapps/terrain/stubs/video_source.py @@ -9,6 +9,7 @@ import os from logging import getLogger LOGGER = getLogger(__name__) + class VideoSourceRequestHandler(SimpleHTTPRequestHandler): """ Request handler for serving video sources locally. diff --git a/common/djangoapps/user_api/tests/factories.py b/common/djangoapps/user_api/tests/factories.py index 8d32f17142..9aafc0d661 100644 --- a/common/djangoapps/user_api/tests/factories.py +++ b/common/djangoapps/user_api/tests/factories.py @@ -5,6 +5,7 @@ from student.tests.factories import UserFactory from user_api.models import UserPreference, UserCourseTag from opaque_keys.edx.locations import SlashSeparatedCourseKey + # Factories don't have __init__ methods, and are self documenting # pylint: disable=W0232, C0111 class UserPreferenceFactory(DjangoModelFactory): diff --git a/common/djangoapps/util/bad_request_rate_limiter.py b/common/djangoapps/util/bad_request_rate_limiter.py index a8fb0f9180..381289f639 100644 --- a/common/djangoapps/util/bad_request_rate_limiter.py +++ b/common/djangoapps/util/bad_request_rate_limiter.py @@ -4,6 +4,7 @@ which can be used for rate limiting """ from ratelimitbackend.backends import RateLimitMixin + class BadRequestRateLimiter(RateLimitMixin): """ Use the 3rd party RateLimitMixin to help do rate limiting on the Password Reset flows diff --git a/common/djangoapps/util/string_utils.py b/common/djangoapps/util/string_utils.py index e2d547c5e3..43b3a1dc92 100644 --- a/common/djangoapps/util/string_utils.py +++ b/common/djangoapps/util/string_utils.py @@ -2,6 +2,7 @@ Utilities for string manipulation. """ + def str_to_bool(str): """ Converts "true" (case-insensitive) to the boolean True. diff --git a/common/djangoapps/util/tests/test_string_utils.py b/common/djangoapps/util/tests/test_string_utils.py index b3bdea3411..84cbf1e469 100644 --- a/common/djangoapps/util/tests/test_string_utils.py +++ b/common/djangoapps/util/tests/test_string_utils.py @@ -5,6 +5,7 @@ Tests for string_utils.py from django.test import TestCase from util.string_utils import str_to_bool + class StringUtilsTest(TestCase): """ Tests for str_to_bool. diff --git a/common/lib/calc/calc/tests/test_calc.py b/common/lib/calc/calc/tests/test_calc.py index 9d7f3a0199..eacc34fa1c 100644 --- a/common/lib/calc/calc/tests/test_calc.py +++ b/common/lib/calc/calc/tests/test_calc.py @@ -14,6 +14,7 @@ from pyparsing import ParseException # See http://docs.scipy.org/doc/numpy/reference/generated/numpy.seterr.html numpy.seterr(all='ignore') # Also: 'ignore', 'warn' (default), 'raise' + class EvaluatorTest(unittest.TestCase): """ Run tests for calc.evaluator diff --git a/common/lib/capa/capa/registry.py b/common/lib/capa/capa/registry.py index bcc002c046..fedb029fe2 100644 --- a/common/lib/capa/capa/registry.py +++ b/common/lib/capa/capa/registry.py @@ -1,5 +1,6 @@ """A registry for finding classes based on tags in the class.""" + class TagRegistry(object): """ A registry mapping tags to handlers. diff --git a/common/lib/capa/capa/safe_exec/lazymod.py b/common/lib/capa/capa/safe_exec/lazymod.py index cdd8410f2c..d8d6115ca3 100644 --- a/common/lib/capa/capa/safe_exec/lazymod.py +++ b/common/lib/capa/capa/safe_exec/lazymod.py @@ -7,6 +7,7 @@ in the public domain. import sys + class LazyModule(object): """A lazy module proxy.""" diff --git a/common/lib/capa/capa/tests/test_input_templates.py b/common/lib/capa/capa/tests/test_input_templates.py index ac2268ae7c..2dc90237c6 100644 --- a/common/lib/capa/capa/tests/test_input_templates.py +++ b/common/lib/capa/capa/tests/test_input_templates.py @@ -11,6 +11,7 @@ from mako.template import Template as MakoTemplate from mako import exceptions from capa.inputtypes import Status + class TemplateError(Exception): """ Error occurred while rendering a Mako template. @@ -497,6 +498,7 @@ class FormulaEquationInputTemplateTest(TemplateTestCase): self.assert_has_xpath(xml, "//input[@size='40']", self.context) + class AnnotationInputTemplateTest(TemplateTestCase): """ Test mako template for `` input. diff --git a/common/lib/django_startup.py b/common/lib/django_startup.py index 1980420e0d..19f0f8babe 100644 --- a/common/lib/django_startup.py +++ b/common/lib/django_startup.py @@ -5,6 +5,7 @@ Automatic execution of startup modules in Django apps. from importlib import import_module from django.conf import settings + def autostartup(): """ Execute app.startup:run() for all installed django apps diff --git a/common/lib/symmath/symmath/test_symmath_check.py b/common/lib/symmath/symmath/test_symmath_check.py index 3b8f14b0d2..222cbdd0b6 100644 --- a/common/lib/symmath/symmath/test_symmath_check.py +++ b/common/lib/symmath/symmath/test_symmath_check.py @@ -1,6 +1,7 @@ from unittest import TestCase from .symmath_check import symmath_check + class SymmathCheckTest(TestCase): def test_symmath_check_integers(self): number_list = [i for i in range(-100, 100)] diff --git a/common/lib/tempdir.py b/common/lib/tempdir.py index 0acd92ba33..b3f10b22e0 100644 --- a/common/lib/tempdir.py +++ b/common/lib/tempdir.py @@ -5,12 +5,14 @@ import os.path import shutil import tempfile + def mkdtemp_clean(suffix="", prefix="tmp", dir=None): """Just like mkdtemp, but the directory will be deleted when the process ends.""" the_dir = tempfile.mkdtemp(suffix=suffix, prefix=prefix, dir=dir) atexit.register(cleanup_tempdir, the_dir) return the_dir + def cleanup_tempdir(the_dir): """Called on process exit to remove a temp directory.""" if os.path.exists(the_dir): diff --git a/common/lib/xmodule/xmodule/annotator_mixin.py b/common/lib/xmodule/xmodule/annotator_mixin.py index aa0a19d4a8..aa597702db 100644 --- a/common/lib/xmodule/xmodule/annotator_mixin.py +++ b/common/lib/xmodule/xmodule/annotator_mixin.py @@ -7,6 +7,7 @@ from urlparse import urlparse from os.path import splitext, basename from HTMLParser import HTMLParser + def get_instructions(xmltree): """ Removes from the xmltree and returns them as a string, otherwise None. """ instructions = xmltree.find('instructions') diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 3a829d37ca..54f9d0dfa1 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -28,6 +28,7 @@ CATALOG_VISIBILITY_CATALOG_AND_ABOUT = "both" CATALOG_VISIBILITY_ABOUT = "about" CATALOG_VISIBILITY_NONE = "none" + class StringOrDate(Date): def from_json(self, value): """ @@ -589,6 +590,7 @@ class CourseFields(object): {"display_name": _("None"), "value": CATALOG_VISIBILITY_NONE}] ) + class CourseDescriptor(CourseFields, SequenceDescriptor): module_class = SequenceModule diff --git a/common/lib/xmodule/xmodule/lti_module.py b/common/lib/xmodule/xmodule/lti_module.py index 1da01cd9d4..d929e91e86 100644 --- a/common/lib/xmodule/xmodule/lti_module.py +++ b/common/lib/xmodule/xmodule/lti_module.py @@ -842,6 +842,7 @@ oauth_consumer_key="", oauth_signature="frVp4JuvT1mVXlxktiAUjQ7%2F1cw%3D"'} return key, secret return '', '' + class LTIDescriptor(LTIFields, MetadataOnlyEditingDescriptor, EmptyDataRawDescriptor): """ Descriptor for LTI Xmodule. diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py index 8b94851480..8756a39842 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py @@ -2690,6 +2690,7 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase): """ self.db_connection.ensure_indexes() + class SparseList(list): """ Enable inserting items into a list in arbitrary order and then retrieving them. diff --git a/common/lib/xmodule/xmodule/modulestore/tests/persistent_factories.py b/common/lib/xmodule/xmodule/modulestore/tests/persistent_factories.py index bf00f73cf5..a292212a1a 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/persistent_factories.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/persistent_factories.py @@ -8,6 +8,7 @@ from opaque_keys.edx.keys import UsageKey # Factories don't have __init__ methods, and are self documenting # pylint: disable=W0232, C0111 + class SplitFactory(factory.Factory): """ Abstracted superclass which defines modulestore so that there's no dependency on django diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_modulestore_settings.py b/common/lib/xmodule/xmodule/modulestore/tests/test_modulestore_settings.py index 3889530d25..56cf3bd46e 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_modulestore_settings.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_modulestore_settings.py @@ -12,6 +12,7 @@ from xmodule.modulestore.modulestore_settings import ( get_mixed_stores, ) + @ddt.ddt class ModuleStoreSettingsMigration(TestCase): """ diff --git a/common/lib/xmodule/xmodule/modulestore/xml_importer.py b/common/lib/xmodule/xmodule/modulestore/xml_importer.py index 1af5ea27b4..92a0bb28bd 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/xml_importer.py @@ -390,6 +390,7 @@ def _import_static_content_wrapper(static_content_store, do_import_static, cours dest_course_id, subpath=simport, verbose=verbose ) + def _import_module_and_update_references( module, store, user_id, source_course_id, dest_course_id, diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/controller_query_service.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/controller_query_service.py index bd5c4d592a..b20c0279bc 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/controller_query_service.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/controller_query_service.py @@ -168,6 +168,7 @@ class MockControllerQueryService(object): """ pass + def convert_seconds_to_human_readable(seconds): if seconds < 60: human_string = "{0} seconds".format(seconds) diff --git a/common/lib/xmodule/xmodule/split_test_module.py b/common/lib/xmodule/xmodule/split_test_module.py index 890afb75dc..fdd4629a9a 100644 --- a/common/lib/xmodule/xmodule/split_test_module.py +++ b/common/lib/xmodule/xmodule/split_test_module.py @@ -357,6 +357,7 @@ class SplitTestModule(SplitTestFields, XModule, StudioEditableModule): """ return self.descriptor.validate() + @XBlock.needs('user_tags') # pylint: disable=abstract-method @XBlock.wants('partitions') @XBlock.wants('user') diff --git a/common/lib/xmodule/xmodule/tabs.py b/common/lib/xmodule/xmodule/tabs.py index 64dfe0ee30..5ad8f58c48 100644 --- a/common/lib/xmodule/xmodule/tabs.py +++ b/common/lib/xmodule/xmodule/tabs.py @@ -225,6 +225,7 @@ class StaffTab(AuthenticatedCourseTab): def can_display(self, course, settings, is_user_authenticated, is_user_staff, is_user_enrolled): # pylint: disable=unused-argument return is_user_staff + class EnrolledOrStaffTab(CourseTab): """ Abstract class for tabs that can be accessed by only users with staff access diff --git a/common/lib/xmodule/xmodule/tests/rendering/core.py b/common/lib/xmodule/xmodule/tests/rendering/core.py index 1324af853c..acae995397 100644 --- a/common/lib/xmodule/xmodule/tests/rendering/core.py +++ b/common/lib/xmodule/xmodule/tests/rendering/core.py @@ -40,6 +40,7 @@ import lxml.etree from singledispatch import singledispatch + @singledispatch def assert_student_view_valid_html(block, html): """ diff --git a/common/lib/xmodule/xmodule/tests/test_bulk_assertions.py b/common/lib/xmodule/xmodule/tests/test_bulk_assertions.py index d796b6b546..a6a2860a4e 100644 --- a/common/lib/xmodule/xmodule/tests/test_bulk_assertions.py +++ b/common/lib/xmodule/xmodule/tests/test_bulk_assertions.py @@ -1,6 +1,7 @@ import ddt from xmodule.tests import BulkAssertionTest + @ddt.ddt class TestBulkAssertionTestCase(BulkAssertionTest): diff --git a/common/lib/xmodule/xmodule/tests/test_capa_module.py b/common/lib/xmodule/xmodule/tests/test_capa_module.py index 5208b17382..06ea77d152 100644 --- a/common/lib/xmodule/xmodule/tests/test_capa_module.py +++ b/common/lib/xmodule/xmodule/tests/test_capa_module.py @@ -142,6 +142,7 @@ class CapaFactory(object): return module + class CapaFactoryWithFiles(CapaFactory): """ A factory for creating a Capa problem with files attached. diff --git a/common/lib/xmodule/xmodule/tests/test_content.py b/common/lib/xmodule/xmodule/tests/test_content.py index 457a4a22b2..5c9c50c4be 100644 --- a/common/lib/xmodule/xmodule/tests/test_content.py +++ b/common/lib/xmodule/xmodule/tests/test_content.py @@ -44,6 +44,7 @@ Various versions have evolved over the years, sometimes by accident, sometimes o injected humour and the like). """ + class Content: def __init__(self, location, content_type): self.location = location diff --git a/common/lib/xmodule/xmodule/tests/test_utils_django.py b/common/lib/xmodule/xmodule/tests/test_utils_django.py index 36a3b0c272..dfa86a23ea 100644 --- a/common/lib/xmodule/xmodule/tests/test_utils_django.py +++ b/common/lib/xmodule/xmodule/tests/test_utils_django.py @@ -3,6 +3,7 @@ from xmodule.util.django import get_current_request, get_current_request_hostnam from nose.tools import assert_is_none from unittest import TestCase + class UtilDjangoTests(TestCase): """ Tests for methods exposed in util/django diff --git a/common/lib/xmodule/xmodule/timeinfo.py b/common/lib/xmodule/xmodule/timeinfo.py index a55cbe3a63..17ac38de52 100644 --- a/common/lib/xmodule/xmodule/timeinfo.py +++ b/common/lib/xmodule/xmodule/timeinfo.py @@ -2,6 +2,7 @@ import logging from xmodule.fields import Timedelta log = logging.getLogger(__name__) + class TimeInfo(object): """ This is a simple object that calculates and stores datetime information for an XModule diff --git a/common/lib/xmodule/xmodule/video_module/transcripts_utils.py b/common/lib/xmodule/xmodule/video_module/transcripts_utils.py index a6b1da42a3..857cc6b5d2 100644 --- a/common/lib/xmodule/xmodule/video_module/transcripts_utils.py +++ b/common/lib/xmodule/xmodule/video_module/transcripts_utils.py @@ -75,6 +75,7 @@ def save_to_store(content, name, mime_type, location): contentstore().save(content) return content_location + def save_subs_to_store(subs, subs_id, item, language='en'): """ Save transcripts into `StaticContent`. @@ -90,6 +91,7 @@ def save_subs_to_store(subs, subs_id, item, language='en'): filename = subs_filename(subs_id, language) return save_to_store(filedata, filename, 'application/json', item.location) + def get_transcripts_from_youtube(youtube_id, settings, i18n): """ Gets transcripts from youtube for youtube_id. @@ -428,6 +430,7 @@ def get_or_create_sjson(item): sjson_transcript = Transcript.asset(item.location, source_subs_id, item.transcript_language).data return sjson_transcript + class Transcript(object): """ Container for transcript methods. diff --git a/common/test/acceptance/fixtures/discussion.py b/common/test/acceptance/fixtures/discussion.py index a521a36c8e..c14b2cf56e 100644 --- a/common/test/acceptance/fixtures/discussion.py +++ b/common/test/acceptance/fixtures/discussion.py @@ -42,6 +42,7 @@ class Thread(ContentFactory): pinned = False read = False + class Comment(ContentFactory): thread_id = None depth = 0 diff --git a/common/test/acceptance/pages/studio/overview.py b/common/test/acceptance/pages/studio/overview.py index 50d25ba959..21be0b833b 100644 --- a/common/test/acceptance/pages/studio/overview.py +++ b/common/test/acceptance/pages/studio/overview.py @@ -307,6 +307,7 @@ class CourseOutlineChild(PageObject, CourseOutlineItem): grand_locators = [grandkid.locator for grandkid in grandkids] return [descendant for descendant in descendants if not descendant.locator in grand_locators] + class CourseOutlineUnit(CourseOutlineChild): """ PageObject that wraps a unit link on the Studio Course Outline page. @@ -329,6 +330,7 @@ class CourseOutlineUnit(CourseOutlineChild): return self.q(css=self._bounded_selector(self.BODY_SELECTOR)).map( lambda el: CourseOutlineUnit(self.browser, el.get_attribute('data-locator'))).results + class CourseOutlineSubsection(CourseOutlineContainer, CourseOutlineChild): """ :class`.PageObject` that wraps a subsection block on the Studio Course Outline page. diff --git a/common/test/acceptance/performance/test_studio_performance.py b/common/test/acceptance/performance/test_studio_performance.py index 743c51902a..4886e03b45 100644 --- a/common/test/acceptance/performance/test_studio_performance.py +++ b/common/test/acceptance/performance/test_studio_performance.py @@ -6,6 +6,7 @@ from ..pages.studio.auto_auth import AutoAuthPage from ..pages.studio.overview import CourseOutlinePage from nose.plugins.attrib import attr + @attr(har_mode='explicit') class StudioPagePerformanceTest(WebAppTest): """ diff --git a/common/test/data/uploads/python_lib_zip/number_helpers.py b/common/test/data/uploads/python_lib_zip/number_helpers.py index a79b13b529..04db8e9bfe 100644 --- a/common/test/data/uploads/python_lib_zip/number_helpers.py +++ b/common/test/data/uploads/python_lib_zip/number_helpers.py @@ -1,5 +1,6 @@ def seventeen(): return 17 + def fortytwo(x): return 42+x diff --git a/docs/en_us/developers/source/conf.py b/docs/en_us/developers/source/conf.py index 41576c141c..a3b9d6a01a 100644 --- a/docs/en_us/developers/source/conf.py +++ b/docs/en_us/developers/source/conf.py @@ -83,6 +83,7 @@ copyright = u'2014, edX' # Mock all the modules that the readthedocs build can't import + class Mock(object): def __init__(self, *args, **kwargs): pass diff --git a/docs/en_us/platform_api/source/conf.py b/docs/en_us/platform_api/source/conf.py index 0cacceef97..b0fcd45019 100644 --- a/docs/en_us/platform_api/source/conf.py +++ b/docs/en_us/platform_api/source/conf.py @@ -74,6 +74,7 @@ copyright = u'2014, edX' # Mock all the modules that the readthedocs build can't import + class Mock(object): def __init__(self, *args, **kwargs): pass diff --git a/docs/shared/conf.py b/docs/shared/conf.py index 91ce9ef1da..1659291e99 100644 --- a/docs/shared/conf.py +++ b/docs/shared/conf.py @@ -25,6 +25,7 @@ import sys, os BASEDIR = os.path.dirname(os.path.abspath(__file__)) + def add_base(paths): """ Returns a list of paths relative to BASEDIR. diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index 33b8548067..616040d13e 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -259,6 +259,7 @@ def get_course_info_section_module(request, course, section_key): static_asset_path=course.static_asset_path ) + def get_course_info_section(request, course, section_key): """ This returns the snippet of html to be rendered on the course info page, diff --git a/lms/djangoapps/courseware/features/events.py b/lms/djangoapps/courseware/features/events.py index b4b1d5001a..4f0d9adccf 100644 --- a/lms/djangoapps/courseware/features/events.py +++ b/lms/djangoapps/courseware/features/events.py @@ -41,6 +41,7 @@ def course_url_event_is_emitted(_step, url_regex): event_type = url_regex.format(world.scenario_dict['COURSE'].id) n_events_are_emitted(_step, 1, event_type, "server") + @step(r'([aA]n?|\d+) "(.*)" (server|browser) events? is emitted$') def n_events_are_emitted(_step, count, event_type, event_source): diff --git a/lms/djangoapps/courseware/features/gst.py b/lms/djangoapps/courseware/features/gst.py index bbb0c76f6a..3ce668e3f1 100644 --- a/lms/djangoapps/courseware/features/gst.py +++ b/lms/djangoapps/courseware/features/gst.py @@ -26,6 +26,7 @@ DEFAULT_DATA = """\ """ + @steps class GraphicalSliderToolSteps(object): COURSE_NUM = 'test_course' diff --git a/lms/djangoapps/courseware/grades.py b/lms/djangoapps/courseware/grades.py index 61781dbc78..48e30837ed 100644 --- a/lms/djangoapps/courseware/grades.py +++ b/lms/djangoapps/courseware/grades.py @@ -140,6 +140,7 @@ def answer_distributions(course_key): return answer_counts + @transaction.commit_manually def grade(student, request, course, keep_raw_scores=False): """ diff --git a/lms/djangoapps/courseware/middleware.py b/lms/djangoapps/courseware/middleware.py index 7ef0844db5..60b803601a 100644 --- a/lms/djangoapps/courseware/middleware.py +++ b/lms/djangoapps/courseware/middleware.py @@ -7,6 +7,7 @@ from django.core.urlresolvers import reverse from courseware.courses import UserNotEnrolled + class RedirectUnenrolledMiddleware(object): """ Catch UserNotEnrolled errors thrown by `get_course_with_access` and redirect diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index c948cd3d3d..98d44fe9df 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -72,6 +72,7 @@ XQUEUE_INTERFACE = XQueueInterface( # Some brave person should make the variable names consistently someday, but the code's # coupled enough that it's kind of tricky--you've been warned! + class LmsModuleRenderError(Exception): """ An exception class for exceptions thrown by module_render that don't fit well elsewhere diff --git a/lms/djangoapps/courseware/tests/test_access.py b/lms/djangoapps/courseware/tests/test_access.py index 928fcb6c26..c2f6ea2b81 100644 --- a/lms/djangoapps/courseware/tests/test_access.py +++ b/lms/djangoapps/courseware/tests/test_access.py @@ -18,6 +18,7 @@ from xmodule.course_module import ( # pylint: disable=C0111 # pylint: disable=W0212 + class AccessTestCase(TestCase): """ Tests for the various access controls on the student dashboard diff --git a/lms/djangoapps/courseware/tests/test_microsites.py b/lms/djangoapps/courseware/tests/test_microsites.py index 2f34de8e14..95c68f8689 100644 --- a/lms/djangoapps/courseware/tests/test_microsites.py +++ b/lms/djangoapps/courseware/tests/test_microsites.py @@ -14,6 +14,7 @@ from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE from xmodule.course_module import ( CATALOG_VISIBILITY_CATALOG_AND_ABOUT, CATALOG_VISIBILITY_NONE) + @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase): """ diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 6cb05bd0a9..5887aa6489 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -838,6 +838,7 @@ def mktg_course_about(request, course_id): if force_english: translation.deactivate() + @login_required @cache_control(no_cache=True, no_store=True, must_revalidate=True) @transaction.commit_manually diff --git a/lms/djangoapps/dashboard/git_import.py b/lms/djangoapps/dashboard/git_import.py index 1fcf322ec1..0e4b27bb23 100644 --- a/lms/djangoapps/dashboard/git_import.py +++ b/lms/djangoapps/dashboard/git_import.py @@ -51,6 +51,7 @@ class GitImportError(Exception): CANNOT_BRANCH = _('Unable to switch to specified branch. Please check ' 'your branch name.') + def cmd_log(cmd, cwd): """ Helper function to redirect stderr to stdout and log the command diff --git a/lms/djangoapps/dashboard/management/commands/git_add_course.py b/lms/djangoapps/dashboard/management/commands/git_add_course.py index da02a438a6..d97a04b881 100644 --- a/lms/djangoapps/dashboard/management/commands/git_add_course.py +++ b/lms/djangoapps/dashboard/management/commands/git_add_course.py @@ -14,6 +14,7 @@ from xmodule.modulestore.xml import XMLModuleStore log = logging.getLogger(__name__) + class Command(BaseCommand): """ Pull a git repo and import into the mongo based content database. diff --git a/lms/djangoapps/django_comment_client/forum/tests.py b/lms/djangoapps/django_comment_client/forum/tests.py index 7855271be0..2bec1572ed 100644 --- a/lms/djangoapps/django_comment_client/forum/tests.py +++ b/lms/djangoapps/django_comment_client/forum/tests.py @@ -569,6 +569,7 @@ class ForumFormDiscussionGroupIdTestCase(CohortedContentTestCase, CohortedTopicG response, lambda d: d['discussion_data'][0] ) + @patch('lms.lib.comment_client.utils.requests.request') class UserProfileDiscussionGroupIdTestCase(CohortedContentTestCase, CohortedTopicGroupIdTestMixin): cs_endpoint = "/active_threads" diff --git a/lms/djangoapps/django_comment_client/tests/group_id.py b/lms/djangoapps/django_comment_client/tests/group_id.py index 23f965c771..943a257ef4 100644 --- a/lms/djangoapps/django_comment_client/tests/group_id.py +++ b/lms/djangoapps/django_comment_client/tests/group_id.py @@ -3,6 +3,7 @@ import re from course_groups.models import CourseUserGroup + class GroupIdAssertionMixin(object): def _data_or_params_cs_request(self, mock_request): """ diff --git a/lms/djangoapps/django_comment_client/tests/unicode.py b/lms/djangoapps/django_comment_client/tests/unicode.py index 4240d2636e..700d31be15 100644 --- a/lms/djangoapps/django_comment_client/tests/unicode.py +++ b/lms/djangoapps/django_comment_client/tests/unicode.py @@ -1,5 +1,6 @@ # coding=utf-8 + class UnicodeTestMixin(object): def test_ascii(self): self._test_unicode_data(u"This post contains ASCII.") diff --git a/lms/djangoapps/django_comment_client/tests/utils.py b/lms/djangoapps/django_comment_client/tests/utils.py index 2c1cc371ec..38b4c48e6d 100644 --- a/lms/djangoapps/django_comment_client/tests/utils.py +++ b/lms/djangoapps/django_comment_client/tests/utils.py @@ -9,6 +9,7 @@ from student.tests.factories import CourseEnrollmentFactory, UserFactory from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase + @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) class CohortedContentTestCase(ModuleStoreTestCase): """ diff --git a/lms/djangoapps/instructor/management/commands/openended_post.py b/lms/djangoapps/instructor/management/commands/openended_post.py index 8f7992c358..79018de7a5 100644 --- a/lms/djangoapps/instructor/management/commands/openended_post.py +++ b/lms/djangoapps/instructor/management/commands/openended_post.py @@ -112,6 +112,7 @@ def post_submission_for_student(student, course, location, task_number, dry_run= return False + class DummyRequest(object): """Dummy request""" diff --git a/lms/djangoapps/instructor/offline_gradecalc.py b/lms/djangoapps/instructor/offline_gradecalc.py index 9c77bc276e..83bb5f72d8 100644 --- a/lms/djangoapps/instructor/offline_gradecalc.py +++ b/lms/djangoapps/instructor/offline_gradecalc.py @@ -16,6 +16,7 @@ from django.contrib.auth.models import User from instructor.utils import DummyRequest + class MyEncoder(JSONEncoder): def _iterencode(self, obj, markers=None): diff --git a/lms/djangoapps/instructor/views/legacy.py b/lms/djangoapps/instructor/views/legacy.py index 728b04777a..c3e2a65fbd 100644 --- a/lms/djangoapps/instructor/views/legacy.py +++ b/lms/djangoapps/instructor/views/legacy.py @@ -1431,6 +1431,7 @@ def get_student_grade_summary_data(request, course, get_grades=True, get_raw_sco #----------------------------------------------------------------------------- # enrollment + def _do_enroll_students(course, course_key, students, secure=False, overload=False, auto_enroll=False, email_students=False, is_shib_course=False): """ Do the actual work of enrolling multiple students, presented as a string diff --git a/lms/djangoapps/instructor_task/admin.py b/lms/djangoapps/instructor_task/admin.py index f453c6dbb5..2d70a065b6 100644 --- a/lms/djangoapps/instructor_task/admin.py +++ b/lms/djangoapps/instructor_task/admin.py @@ -8,6 +8,7 @@ a task. from django.contrib import admin from .models import InstructorTask + class InstructorTaskAdmin(admin.ModelAdmin): list_display = [ 'task_id', diff --git a/lms/djangoapps/notification_prefs/views.py b/lms/djangoapps/notification_prefs/views.py index e1d64cb84f..6bcb60a489 100644 --- a/lms/djangoapps/notification_prefs/views.py +++ b/lms/djangoapps/notification_prefs/views.py @@ -132,6 +132,7 @@ def ajax_disable(request): return HttpResponse(status=204) + @require_GET def ajax_status(request): """ diff --git a/lms/djangoapps/open_ended_grading/staff_grading_service.py b/lms/djangoapps/open_ended_grading/staff_grading_service.py index c6042d3f51..d67376591b 100644 --- a/lms/djangoapps/open_ended_grading/staff_grading_service.py +++ b/lms/djangoapps/open_ended_grading/staff_grading_service.py @@ -278,6 +278,7 @@ def get_next(request, course_id): return HttpResponse(json.dumps(_get_next(course_key, grader_id, location)), mimetype="application/json") + def get_problem_list(request, course_id): """ Get all the problems for the given course id diff --git a/lms/djangoapps/shoppingcart/exceptions.py b/lms/djangoapps/shoppingcart/exceptions.py index 1a1f944e71..6253c3bc46 100644 --- a/lms/djangoapps/shoppingcart/exceptions.py +++ b/lms/djangoapps/shoppingcart/exceptions.py @@ -4,6 +4,7 @@ Exceptions for the shoppingcart app # (Exception Class Names are sort of self-explanatory, so skipping docstring requirement) # pylint: disable=C0111 + class PaymentException(Exception): pass diff --git a/lms/djangoapps/shoppingcart/processors/exceptions.py b/lms/djangoapps/shoppingcart/processors/exceptions.py index 2bcf35e50f..47a51a8b60 100644 --- a/lms/djangoapps/shoppingcart/processors/exceptions.py +++ b/lms/djangoapps/shoppingcart/processors/exceptions.py @@ -16,5 +16,6 @@ class CCProcessorDataException(CCProcessorException): class CCProcessorWrongAmountException(CCProcessorException): pass + class CCProcessorUserCancelled(CCProcessorException): pass diff --git a/lms/djangoapps/shoppingcart/tests/test_models.py b/lms/djangoapps/shoppingcart/tests/test_models.py index d2d992b89f..e1624ee730 100644 --- a/lms/djangoapps/shoppingcart/tests/test_models.py +++ b/lms/djangoapps/shoppingcart/tests/test_models.py @@ -37,6 +37,7 @@ from opaque_keys.edx.locator import CourseLocator # that disables the XML modulestore. MODULESTORE_CONFIG = mixed_store_config(settings.COMMON_TEST_DATA_ROOT, {}, include_xml=False) + @override_settings(MODULESTORE=MODULESTORE_CONFIG) class OrderTest(ModuleStoreTestCase): def setUp(self): diff --git a/lms/djangoapps/shoppingcart/views.py b/lms/djangoapps/shoppingcart/views.py index 53c72219ab..24cfd56fcc 100644 --- a/lms/djangoapps/shoppingcart/views.py +++ b/lms/djangoapps/shoppingcart/views.py @@ -196,6 +196,7 @@ def remove_item(request): return HttpResponse('OK') + def remove_code_redemption(order_item_course_id, item_id, item, user): """ If an item removed from shopping cart then we will remove diff --git a/lms/djangoapps/staticbook/views.py b/lms/djangoapps/staticbook/views.py index eda28d9b7a..4d454f90f8 100644 --- a/lms/djangoapps/staticbook/views.py +++ b/lms/djangoapps/staticbook/views.py @@ -130,6 +130,7 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None): }, ) + @login_required def html_index(request, course_id, book_index, chapter=None): """ diff --git a/lms/djangoapps/verify_student/tests/test_ssencrypt.py b/lms/djangoapps/verify_student/tests/test_ssencrypt.py index 1e9978be7c..c2a6c3646f 100644 --- a/lms/djangoapps/verify_student/tests/test_ssencrypt.py +++ b/lms/djangoapps/verify_student/tests/test_ssencrypt.py @@ -7,6 +7,7 @@ from verify_student.ssencrypt import ( rsa_decrypt, rsa_encrypt, random_aes_key ) + def test_aes(): key_str = "32fe72aaf2abb44de9e161131b5435c8d37cbdb6f5df242ae860b283115f2dae" key = key_str.decode("hex") @@ -28,6 +29,7 @@ def test_aes(): assert_roundtrip("") assert_roundtrip("\xe9\xe1a\x13\x1bT5\xc8") # Random, non-ASCII text + def test_rsa(): # Make up some garbage keys for testing purposes. pub_key_str = """-----BEGIN PUBLIC KEY----- diff --git a/manage.py b/manage.py index c75dbf389e..c14d386e87 100755 --- a/manage.py +++ b/manage.py @@ -21,6 +21,7 @@ import importlib from argparse import ArgumentParser import contracts + def parse_args(): """Parse edx specific arguments to manage.py""" parser = ArgumentParser() diff --git a/pavelib/acceptance_test.py b/pavelib/acceptance_test.py index 1d9ddf2e30..2389af7d3d 100644 --- a/pavelib/acceptance_test.py +++ b/pavelib/acceptance_test.py @@ -12,6 +12,7 @@ except ImportError: __test__ = False # do not collect + @task @needs( 'pavelib.prereqs.install_prereqs', diff --git a/pavelib/i18n.py b/pavelib/i18n.py index aa43d4f0ba..c3dfaf2862 100644 --- a/pavelib/i18n.py +++ b/pavelib/i18n.py @@ -168,6 +168,7 @@ def i18n_ltr(): sh('git add conf/locale') sh('git commit --amend') + @task @needs( "pavelib.i18n.i18n_transifex_pull", diff --git a/pavelib/paver_tests/test_paver_quality.py b/pavelib/paver_tests/test_paver_quality.py index 21682fc72c..018d7e7e68 100644 --- a/pavelib/paver_tests/test_paver_quality.py +++ b/pavelib/paver_tests/test_paver_quality.py @@ -8,6 +8,7 @@ import pavelib.quality import paver.easy from paver.easy import BuildFailure + @ddt class TestPaverQualityViolations(unittest.TestCase): diff --git a/pavelib/quality.py b/pavelib/quality.py index 887b0997a8..3333978087 100644 --- a/pavelib/quality.py +++ b/pavelib/quality.py @@ -65,6 +65,7 @@ def run_pylint(options): raise Exception("Failed. Too many pylint violations. " "The limit is {violations_limit}.".format(violations_limit=violations_limit)) + def _count_pylint_violations(report_file): """ Parses a pylint report line-by-line and determines the number of violations reported @@ -83,6 +84,7 @@ def _count_pylint_violations(report_file): num_violations_report += 1 return num_violations_report + @task @needs('pavelib.prereqs.install_python_prereqs') @cmdopts([ @@ -113,10 +115,12 @@ def run_pep8(options): raise Exception("Failed. Too many pep8 violations. " "The limit is {violations_limit}.".format(violations_limit=violations_limit)) + def _count_pep8_violations(report_file): num_lines = sum(1 for line in open(report_file)) return num_lines + @task @needs('pavelib.prereqs.install_python_prereqs') @cmdopts([ diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index ca4fb12312..b36f8d852d 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -9,6 +9,7 @@ from lazy import lazy from path import path import memcache + class Env(object): """ Load information about the execution environment. diff --git a/pavelib/utils/test/utils.py b/pavelib/utils/test/utils.py index 4520afacfb..e92ae7f201 100644 --- a/pavelib/utils/test/utils.py +++ b/pavelib/utils/test/utils.py @@ -54,6 +54,7 @@ def clean_mongo(): repo_root=Env.REPO_ROOT, )) + def check_firefox_version(): """ Check that firefox is the correct version. diff --git a/scripts/run_watch_data.py b/scripts/run_watch_data.py index 7a7b781da6..08481b48de 100755 --- a/scripts/run_watch_data.py +++ b/scripts/run_watch_data.py @@ -22,6 +22,7 @@ EXTENSIONS = ["*", "xml", "js", "css", "coffee", "scss", "html"] WATCH_DIRS = [os.path.abspath(os.path.normpath(dir)) for dir in WATCH_DIRS] + class DjangoEventHandler(FileSystemEventHandler): def __init__(self, process): diff --git a/scripts/runone.py b/scripts/runone.py index e4dcce8dea..ea25c8365c 100755 --- a/scripts/runone.py +++ b/scripts/runone.py @@ -9,6 +9,7 @@ import sys # to become: # test --settings=cms.envs.test --pythonpath=. -s cms/djangoapps/contentstore/tests/test_course_settings.py:CourseDetailsViewTest.test_update_and_fetch + def find_full_path(path_to_file): """Find the full path where we only have a relative path from somewhere in the tree.""" for subdir, dirs, files in os.walk("."): @@ -16,6 +17,7 @@ def find_full_path(path_to_file): if os.path.exists(full): return full + def main(argv): parser = argparse.ArgumentParser(description="Run just one test") parser.add_argument('--nocapture', '-s', action='store_true', help="Don't capture stdout (any stdout output will be printed immediately)")