Fix simplifiable-range pylint warnings.
This commit is contained in:
@@ -13,7 +13,7 @@ class MemcacheTest(TestCase):
|
||||
"""
|
||||
|
||||
# Test whitespace, control characters, and some non-ASCII UTF-16
|
||||
UNICODE_CHAR_CODES = ([c for c in range(0, 30)] + [127] +
|
||||
UNICODE_CHAR_CODES = (range(30) + [127] +
|
||||
[129, 500, 2 ** 8 - 1, 2 ** 8 + 1, 2 ** 16 - 1])
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -73,12 +73,12 @@ class ResponseXMLFactory(object):
|
||||
question.text = question_text
|
||||
|
||||
# Add the response(s)
|
||||
for i in range(0, int(num_responses)):
|
||||
for __ in range(int(num_responses)):
|
||||
response_element = self.create_response_element(**kwargs)
|
||||
root.append(response_element)
|
||||
|
||||
# Add input elements
|
||||
for j in range(0, int(num_inputs)):
|
||||
for __ in range(int(num_inputs)):
|
||||
input_element = self.create_input_element(**kwargs)
|
||||
if not (None == input_element):
|
||||
response_element.append(input_element)
|
||||
|
||||
@@ -553,14 +553,14 @@ class AnnotationInputTemplateTest(TemplateTestCase):
|
||||
{'id': id_num,
|
||||
'choice': 'correct',
|
||||
'description': '<p>Unescaped <b>HTML {0}</b></p>'.format(id_num)}
|
||||
for id_num in range(0, 5)]
|
||||
for id_num in range(5)]
|
||||
|
||||
xml = self.render_to_xml(self.context)
|
||||
|
||||
# Expect that each option description is visible
|
||||
# with unescaped HTML.
|
||||
# Since the HTML is unescaped, we can traverse the XML tree
|
||||
for id_num in range(0, 5):
|
||||
for id_num in range(5):
|
||||
xpath = "//span[@data-id='{0}']/p/b".format(id_num)
|
||||
self.assert_has_text(xml, xpath, 'HTML {0}'.format(id_num), exact=False)
|
||||
|
||||
@@ -689,7 +689,7 @@ class OptionInputTemplateTest(TemplateTestCase):
|
||||
|
||||
# Create options 0-4, and select option 2
|
||||
self.context['options'] = [(id_num, '<b>Option {0}</b>'.format(id_num))
|
||||
for id_num in range(0, 5)]
|
||||
for id_num in range(5)]
|
||||
self.context['value'] = 2
|
||||
|
||||
xml = self.render_to_xml(self.context)
|
||||
@@ -701,7 +701,7 @@ class OptionInputTemplateTest(TemplateTestCase):
|
||||
# Should have each of the options, with the correct description
|
||||
# The description HTML should NOT be escaped
|
||||
# (that's why we descend into the <b> tag)
|
||||
for id_num in range(0, 5):
|
||||
for id_num in range(5):
|
||||
xpath = "//option[@value='{0}']/b".format(id_num)
|
||||
self.assert_has_text(xml, xpath, 'Option {0}'.format(id_num))
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ class TestLibraries(MixedSplitTestCase):
|
||||
|
||||
def test_get_libraries(self):
|
||||
""" Test get_libraries() """
|
||||
libraries = [LibraryFactory.create(modulestore=self.store) for _ in range(0, 3)]
|
||||
libraries = [LibraryFactory.create(modulestore=self.store) for _ in range(3)]
|
||||
lib_dict = dict([(lib.location.library_key, lib) for lib in libraries])
|
||||
|
||||
lib_list = self.store.get_libraries()
|
||||
|
||||
@@ -107,7 +107,7 @@ class TestSplitCopyTemplate(MixedSplitTestCase):
|
||||
|
||||
# We do the following twice because different methods get used inside
|
||||
# split modulestore on first vs. subsequent publish
|
||||
for __ in range(0, 2):
|
||||
for __ in range(2):
|
||||
# Publish:
|
||||
self.store.publish(problem_key_in_course, self.user_id)
|
||||
# Test that the defaults values are there.
|
||||
|
||||
@@ -665,8 +665,8 @@ class CombinedOpenEndedV1Module(object):
|
||||
last_post_assessment = task.latest_post_assessment(self.system, short_feedback=False, join_feedback=False)
|
||||
if isinstance(last_post_assessment, list):
|
||||
eval_list = []
|
||||
for i in xrange(0, len(last_post_assessment)):
|
||||
eval_list.append(task.format_feedback_with_evaluation(self.system, last_post_assessment[i]))
|
||||
for assess in last_post_assessment:
|
||||
eval_list.append(task.format_feedback_with_evaluation(self.system, assess))
|
||||
last_post_evaluation = "".join(eval_list)
|
||||
else:
|
||||
last_post_evaluation = task.format_feedback_with_evaluation(self.system, last_post_assessment)
|
||||
@@ -1017,7 +1017,7 @@ class CombinedOpenEndedV1Module(object):
|
||||
ugettext = self.system.service(self, "i18n").ugettext
|
||||
status_list = []
|
||||
current_task_human_name = ""
|
||||
for i in xrange(0, len(self.task_xml)):
|
||||
for i in xrange(len(self.task_xml)):
|
||||
human_task_name = self.extract_human_name_from_task(self.task_xml[i])
|
||||
human_task_name = ugettext(human_task_name) # pylint: disable=translation-of-non-string
|
||||
# Extract the name of the current task for screen readers.
|
||||
@@ -1080,16 +1080,16 @@ class CombinedOpenEndedV1Module(object):
|
||||
if self.is_scored:
|
||||
# Finds the maximum score of all student attempts and keeps it.
|
||||
score_mat = []
|
||||
for i in xrange(0, len(self.task_states)):
|
||||
for i in xrange(len(self.task_states)):
|
||||
# For each task, extract all student scores on that task (each attempt for each task)
|
||||
last_response = self.get_last_response(i)
|
||||
score = last_response.get('all_scores', None)
|
||||
if score is not None:
|
||||
# Convert none scores and weight scores properly
|
||||
for z in xrange(0, len(score)):
|
||||
if score[z] is None:
|
||||
score[z] = 0
|
||||
score[z] *= float(weight)
|
||||
for j in xrange(len(score)):
|
||||
if score[j] is None:
|
||||
score[j] = 0
|
||||
score[j] *= float(weight)
|
||||
score_mat.append(score)
|
||||
|
||||
if len(score_mat) > 0:
|
||||
@@ -1219,7 +1219,7 @@ class CombinedOpenEndedV1Descriptor(object):
|
||||
|
||||
def parse_task(k):
|
||||
"""Assumes that xml_object has child k"""
|
||||
return [stringify_children(xml_object.xpath(k)[i]) for i in xrange(0, len(xml_object.xpath(k)))]
|
||||
return [stringify_children(xml_object.xpath(k)[i]) for i in xrange(len(xml_object.xpath(k)))]
|
||||
|
||||
def parse(k):
|
||||
"""Assumes that xml_object has child k"""
|
||||
|
||||
@@ -59,9 +59,9 @@ class CombinedOpenEndedRubric(object):
|
||||
try:
|
||||
rubric_categories = self.extract_categories(rubric_xml)
|
||||
if score_list and len(score_list) == len(rubric_categories):
|
||||
for i in xrange(0, len(rubric_categories)):
|
||||
for i in xrange(len(rubric_categories)):
|
||||
category = rubric_categories[i]
|
||||
for j in xrange(0, len(category['options'])):
|
||||
for j in xrange(len(category['options'])):
|
||||
if score_list[i] == j:
|
||||
rubric_categories[i]['options'][j]['selected'] = True
|
||||
rubric_scores = [cat['score'] for cat in rubric_categories]
|
||||
@@ -315,23 +315,22 @@ class CombinedOpenEndedRubric(object):
|
||||
score_lists = []
|
||||
score_type_list = []
|
||||
feedback_type_list = []
|
||||
for i in xrange(0, len(scores)):
|
||||
for i in xrange(len(scores)):
|
||||
score_cont_list = scores[i]
|
||||
for j in xrange(0, len(score_cont_list)):
|
||||
for j in xrange(len(score_cont_list)):
|
||||
score_list = score_cont_list[j]
|
||||
score_lists.append(score_list)
|
||||
score_type_list.append(score_types[i][j])
|
||||
feedback_type_list.append(feedback_types[i][j])
|
||||
|
||||
score_list_len = len(score_lists[0])
|
||||
for i in xrange(0, len(score_lists)):
|
||||
score_list = score_lists[i]
|
||||
for score_list in score_lists:
|
||||
if len(score_list) != score_list_len:
|
||||
return success, ""
|
||||
|
||||
score_tuples = []
|
||||
for i in xrange(0, len(score_lists)):
|
||||
for j in xrange(0, len(score_lists[i])):
|
||||
for i in xrange(len(score_lists)):
|
||||
for j in xrange(len(score_lists[i])):
|
||||
tuple = [1, j, score_lists[i][j], [], []]
|
||||
score_tuples, tup_ind = CombinedOpenEndedRubric.check_for_tuple_matches(score_tuples, tuple)
|
||||
score_tuples[tup_ind][0] += 1
|
||||
@@ -353,9 +352,9 @@ class CombinedOpenEndedRubric(object):
|
||||
category = tuple[1]
|
||||
score = tuple[2]
|
||||
tup_ind = -1
|
||||
for t in xrange(0, len(tuples)):
|
||||
if tuples[t][1] == category and tuples[t][2] == score:
|
||||
tup_ind = t
|
||||
for ind in xrange(len(tuples)):
|
||||
if tuples[ind][1] == category and tuples[ind][2] == score:
|
||||
tup_ind = ind
|
||||
break
|
||||
|
||||
if tup_ind == -1:
|
||||
|
||||
@@ -574,7 +574,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
|
||||
feedback_dicts = []
|
||||
grader_ids = []
|
||||
submission_ids = []
|
||||
for i in xrange(0, len(score_result['score'])):
|
||||
for i in xrange(len(score_result['score'])):
|
||||
new_score_result = {
|
||||
'score': score_result['score'][i],
|
||||
'feedback': score_result['feedback'][i],
|
||||
@@ -817,7 +817,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
|
||||
"""None if not available"""
|
||||
if not self.child_history:
|
||||
return None
|
||||
return [self.score_for_attempt(index) for index in xrange(0, len(self.child_history))]
|
||||
return [self.score_for_attempt(index) for index in xrange(len(self.child_history))]
|
||||
|
||||
def score_for_attempt(self, index):
|
||||
"""
|
||||
|
||||
@@ -213,7 +213,7 @@ class OpenEndedChild(object):
|
||||
"""None if not available"""
|
||||
if not self.child_history:
|
||||
return None
|
||||
return [self.child_history[i].get('score') for i in xrange(0, len(self.child_history))]
|
||||
return [child_hist.get('score') for child_hist in self.child_history]
|
||||
|
||||
def latest_post_assessment(self, system):
|
||||
"""Empty string if not available"""
|
||||
|
||||
@@ -141,7 +141,7 @@ class LibraryEditPageTest(StudioLibraryTest):
|
||||
Then 10 are displayed.
|
||||
"""
|
||||
self.assertEqual(len(self.lib_page.xblocks), 0)
|
||||
for _ in range(0, 10):
|
||||
for _ in range(10):
|
||||
add_component(self.lib_page, "problem", "Multiple Choice")
|
||||
self.assertEqual(len(self.lib_page.xblocks), 10)
|
||||
add_component(self.lib_page, "problem", "Multiple Choice")
|
||||
|
||||
Reference in New Issue
Block a user