Commit a11f2877 by Sarina Canelake

Merge pull request #6998 from stvstnfrd/quality/pep8

Extend PEP8 coverage
parents 99e85556 41318981
......@@ -12,7 +12,8 @@ COURSELIKE_KEY_PATTERN = r'(?P<course_key_string>({}|{}))'.format(
# Pattern to match a library key only
LIBRARY_KEY_PATTERN = r'(?P<library_key_string>library-v1:[^/+]+\+[^/+]+)'
urlpatterns = patterns('', # nopep8
urlpatterns = patterns(
'',
url(r'^transcripts/upload$', 'contentstore.views.upload_transcripts', name='upload_transcripts'),
url(r'^transcripts/download$', 'contentstore.views.download_transcripts', name='download_transcripts'),
......
from django.conf.urls import url, patterns
urlpatterns = patterns('', # nopep8
urlpatterns = patterns(
'',
url(r'^$', 'heartbeat.views.heartbeat', name='heartbeat'),
)
......@@ -3,7 +3,9 @@ URL patterns for Javascript files used to load all of the XModule JS in one wad.
"""
from django.conf.urls import url, patterns
urlpatterns = patterns('pipeline_js.views', # nopep8
urlpatterns = patterns(
'pipeline_js.views',
url(r'^files\.json$', 'xmodule_js_files', name='xmodule_js_files'),
url(r'^xmodule\.js$', 'requirejs_xmodule', name='requirejs_xmodule'),
)
......@@ -54,8 +54,6 @@ if on_rtd:
else:
os.environ['DJANGO_SETTINGS_MODULE'] = 'lms'
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
......@@ -72,5 +70,3 @@ exclude_patterns = ['build', 'links.rst']
project = u'edX Enrollment API Version 1'
copyright = u'2015, edX'
......@@ -8,15 +8,41 @@ import os
from path import path
import sys
import mock
MOCK_MODULES = ['lxml', 'requests', 'xblock', 'fields', 'xblock.fields',
'frament', 'xblock.fragment', 'webob', 'multidict', 'webob.multidict', 'core',
'xblock.core', 'runtime', 'xblock.runtime', 'sortedcontainers', 'contracts',
'plugin', 'xblock.plugin', 'opaque_keys.edx.asides', 'asides',
'dogstats_wrapper', 'fs', 'fs.errors', 'edxmako', 'edxmako.shortcuts',
'shortcuts', 'crum', 'opaque_keys.edx.locator', 'LibraryLocator', 'Location']
for mod_name in MOCK_MODULES:
MOCK_MODULES = [
'lxml',
'requests',
'xblock',
'fields',
'xblock.fields',
'frament',
'xblock.fragment',
'webob',
'multidict',
'webob.multidict',
'core',
'xblock.core',
'runtime',
'xblock.runtime',
'sortedcontainers',
'contracts',
'plugin',
'xblock.plugin',
'opaque_keys.edx.asides',
'asides',
'dogstats_wrapper',
'fs',
'fs.errors',
'edxmako',
'edxmako.shortcuts',
'shortcuts',
'crum',
'opaque_keys.edx.locator',
'LibraryLocator',
'Location',
]
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = mock.Mock()
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
......@@ -83,5 +109,3 @@ project = u'edX Platform API Version 0.5 Alpha'
copyright = u'2015, edX'
exclude_patterns = ['build', 'links.rst']
......@@ -6,7 +6,9 @@ from django.conf.urls import patterns, url
from django.conf import settings
COURSE_ID_PATTERN = settings.COURSE_ID_PATTERN
urlpatterns = patterns('', # nopep8
urlpatterns = patterns(
'',
# Json request data for metrics for entire course
url(r'^{}/all_sequential_open_distrib$'.format(settings.COURSE_ID_PATTERN),
'class_dashboard.views.all_sequential_open_distrib', name="all_sequential_open_distrib"),
......
from django.conf.urls.defaults import url, patterns
urlpatterns = patterns('django_comment_client.base.views', # nopep8
urlpatterns = patterns(
'django_comment_client.base.views',
url(r'upload$', 'upload', name='upload'),
url(r'threads/(?P<thread_id>[\w\-]+)/update$', 'update_thread', name='update_thread'),
url(r'threads/(?P<thread_id>[\w\-]+)/reply$', 'create_comment', name='create_comment'),
......
from django.conf.urls.defaults import url, patterns
urlpatterns = patterns('django_comment_client.forum.views', # nopep8
urlpatterns = patterns(
'django_comment_client.forum.views',
url(r'users/(?P<user_id>\w+)/followed$', 'followed_threads', name='followed_threads'),
url(r'users/(?P<user_id>\w+)$', 'user_profile', name='user_profile'),
url(r'^(?P<discussion_id>[\w\-.]+)/threads/(?P<thread_id>\w+)$', 'single_thread', name='single_thread'),
......
from django.conf.urls.defaults import url, patterns, include
urlpatterns = patterns('', # nopep8
urlpatterns = patterns(
'',
url(r'forum/?', include('django_comment_client.forum.urls')),
url(r'', include('django_comment_client.base.urls')),
)
......@@ -5,7 +5,9 @@ Instructor API endpoint urls.
from django.conf.urls import patterns, url
urlpatterns = patterns('', # nopep8
urlpatterns = patterns(
'',
url(r'^students_update_enrollment$',
'instructor.views.api.students_update_enrollment', name="students_update_enrollment"),
url(r'^register_and_enroll_students$',
......
from django.conf.urls import patterns, url
from django.conf import settings
urlpatterns = patterns('shoppingcart.views', # nopep8
urlpatterns = patterns(
'shoppingcart.views',
url(r'^postpay_callback/$', 'postpay_callback'), # Both the ~accept and ~reject callback pages are handled here
url(r'^receipt/(?P<ordernum>[0-9]*)/$', 'show_receipt'),
url(r'^donation/$', 'donate', name='donation'),
......
......@@ -5,7 +5,9 @@ URL mappings for the Survey feature
from django.conf.urls import patterns, url
urlpatterns = patterns('survey.views', # nopep8
urlpatterns = patterns(
'survey.views',
url(r'^(?P<survey_name>[0-9A-Za-z]+)/$', 'view_survey', name='view_survey'),
url(r'^(?P<survey_name>[0-9A-Za-z]+)/answers/$', 'submit_answers', name='submit_answers'),
)
......@@ -12,7 +12,9 @@ if settings.DEBUG or settings.FEATURES.get('ENABLE_DJANGO_ADMIN_SITE'):
# Use urlpatterns formatted as within the Django docs with first parameter "stuck" to the open parenthesis
# pylint: disable=bad-continuation
urlpatterns = ('', # nopep8
urlpatterns = (
'',
# certificate view
url(r'^update_certificate$', 'certificates.views.update_certificate'),
url(r'^request_certificate$', 'certificates.views.request_certificate'),
......
......@@ -225,7 +225,6 @@ class TestCohorts(ModuleStoreTestCase):
# get_cohort should return a group for user
self.assertEquals(cohorts.get_cohort(user, course.id).name, "AutoGroup")
def test_auto_cohorting(self):
"""
Make sure cohorts.get_cohort() does the right thing with auto_cohort_groups
......
......@@ -13,23 +13,19 @@ from student.models import UserProfile
TEST_PASSWORD = "test"
@ddt.ddt
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class TestAccountAPI(APITestCase):
def setUp(self):
super(TestAccountAPI, self).setUp()
self.anonymous_client = APIClient()
self.different_user = UserFactory.create(password=TEST_PASSWORD)
self.different_client = APIClient()
self.staff_user = UserFactory(is_staff=True, password=TEST_PASSWORD)
self.staff_client = APIClient()
self.user = UserFactory.create(password=TEST_PASSWORD)
self.url = reverse("accounts_api", kwargs={'username': self.user.username})
def test_get_account_anonymous_user(self):
......
......@@ -157,4 +157,4 @@ class AccountView(APIView):
}
validation_errors['field_errors'] = field_errors
return validation_errors
\ No newline at end of file
return validation_errors
......@@ -1599,4 +1599,3 @@ class UpdateEmailOptInTestCase(ApiTestCase, ModuleStoreTestCase):
self.assertHttpBadRequest(response)
with self.assertRaises(UserOrgTag.DoesNotExist):
UserOrgTag.objects.get(user=self.user, org=self.course.id.org, key="email-optin")
......@@ -10,6 +10,7 @@ def dump_memory(signum, frame):
"""Dump memory stats for the current process to a temp directory. Uses the meliae output format."""
scanner.dump_all_objects('{}/meliae.{}.{}.dump'.format(tempfile.gettempdir(), datetime.now().isoformat(), os.getpid()))
def install_memory_dumper(dump_signal=signal.SIGPROF):
"""
Install a signal handler on `signal` to dump memory stats for the current process.
......
......@@ -95,8 +95,9 @@ def run_bokchoy(**opts):
msg = colorize(
'green',
'Running tests using {default_store} modulestore.'.format(
default_store=test_suite.default_store)
default_store=test_suite.default_store,
)
)
print(msg)
test_suite.run()
......
......@@ -14,15 +14,20 @@ class TestPaverBokChoyCmd(unittest.TestCase):
def _expected_command(self, expected_text_append, expected_default_store=None):
if expected_text_append:
expected_text_append = "/" + expected_text_append
expected_statement = ("DEFAULT_STORE={default_store} SCREENSHOT_DIR='{repo_dir}/test_root/log' "
"BOK_CHOY_HAR_DIR='{repo_dir}/test_root/log/hars' "
"SELENIUM_DRIVER_LOG_DIR='{repo_dir}/test_root/log' "
"nosetests {repo_dir}/common/test/acceptance/tests{exp_text} "
"--with-xunit "
"--xunit-file={repo_dir}/reports/bok_choy/xunit.xml "
"--verbosity=2 ".format(default_store=expected_default_store,
repo_dir=REPO_DIR,
exp_text=expected_text_append))
expected_statement = (
"DEFAULT_STORE={default_store} "
"SCREENSHOT_DIR='{repo_dir}/test_root/log' "
"BOK_CHOY_HAR_DIR='{repo_dir}/test_root/log/hars' "
"SELENIUM_DRIVER_LOG_DIR='{repo_dir}/test_root/log' "
"nosetests {repo_dir}/common/test/acceptance/tests{exp_text} "
"--with-xunit "
"--xunit-file={repo_dir}/reports/bok_choy/xunit.xml "
"--verbosity=2 "
).format(
default_store=expected_default_store,
repo_dir=REPO_DIR,
exp_text=expected_text_append,
)
return expected_statement
def test_default_bokchoy(self):
......
......@@ -31,9 +31,11 @@ class TestPaverQualityViolations(unittest.TestCase):
@file_data('pylint_test_list.json')
def test_pylint_parser_count_violations(self, value):
# Tests:
# * Different types of violations
# * One violation covering multiple lines
"""
Tests:
- Different types of violations
- One violation covering multiple lines
"""
with open(self.f.name, 'w') as f:
f.write(value)
num = pavelib.quality._count_pylint_violations(f.name)
......
......@@ -204,7 +204,6 @@ def coverage(options):
dir=directory
))
call_task('diff_coverage', options=dict(options))
......
......@@ -141,7 +141,7 @@ class SystemTestSuite(NoseTestSuite):
if self.root == 'lms':
default_test_id += " {system}/tests.py".format(system=self.root)
if self.root == 'cms':
default_test_id += " {system}/tests/*".format(system=self.root)
......
"""
Helper functions for test tasks
"""
from __future__ import print_function
from paver.easy import sh, task, cmdopts
from pavelib.utils.envs import Env
import os
......
......@@ -98,7 +98,7 @@ def ensure_pr_fetch():
"""
modified = False
remotes = git.remote().splitlines()
if not "edx" in remotes:
if 'edx' not in remotes:
git.remote("add", "edx", "https://github.com/edx/edx-platform.git")
modified = True
# it would be nice to use the git-python API to do this, but it doesn't seem
......@@ -251,9 +251,9 @@ def ensure_github_creds(attempts=3):
else:
config = {}
# update config
if not "credentials" in config:
if 'credentials' not in config:
config["credentials"] = {}
if not "api.github.com" in config["credentials"]:
if 'api.github.com' not in config['credentials']:
config["credentials"]["api.github.com"] = {}
config["credentials"]["api.github.com"]["username"] = username
config["credentials"]["api.github.com"]["token"] = token
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment