Merge pull request #853 from edx/fix/adam/pylint-pep8

fix pep8 and pylint errors
This commit is contained in:
Adam
2013-09-03 14:22:11 -07:00
5 changed files with 93 additions and 80 deletions

View File

@@ -208,10 +208,10 @@ class InputTypeBase(object):
# end up in a partially-initialized state.
loaded = {}
to_render = set()
for a in self.get_attributes():
loaded[a.name] = a.parse_from_xml(self.xml)
if a.render:
to_render.add(a.name)
for attribute in self.get_attributes():
loaded[attribute.name] = attribute.parse_from_xml(self.xml)
if attribute.render:
to_render.add(attribute.name)
self.loaded_attributes = loaded
self.to_render = to_render
@@ -493,17 +493,17 @@ class JSInput(InputTypeBase):
"""
Register the attributes.
"""
return [Attribute('params', None), # extra iframe params
Attribute('html_file', None),
Attribute('gradefn', "gradefn"),
Attribute('get_statefn', None), # Function to call in iframe
# to get current state.
Attribute('set_statefn', None), # Function to call iframe to
# set state
Attribute('width', "400"), # iframe width
Attribute('height', "300")] # iframe height
return [
Attribute('params', None), # extra iframe params
Attribute('html_file', None),
Attribute('gradefn', "gradefn"),
Attribute('get_statefn', None), # Function to call in iframe
# to get current state.
Attribute('set_statefn', None), # Function to call iframe to
# set state
Attribute('width', "400"), # iframe width
Attribute('height', "300") # iframe height
]
def _extra_context(self):
context = {
@@ -514,7 +514,6 @@ class JSInput(InputTypeBase):
return context
registry.register(JSInput)
#-----------------------------------------------------------------------------
@@ -1048,8 +1047,8 @@ class ChemicalEquationInput(InputTypeBase):
try:
result['preview'] = chemcalc.render_to_html(formula)
except pyparsing.ParseException as p:
result['error'] = u"Couldn't parse formula: {0}".format(p.msg)
except pyparsing.ParseException as err:
result['error'] = u"Couldn't parse formula: {0}".format(err.msg)
except Exception:
# this is unexpected, so log
log.warning(
@@ -1189,15 +1188,19 @@ class DragAndDropInput(InputTypeBase):
'can_reuse': smth}.
"""
tag_attrs = dict()
tag_attrs['draggable'] = {'id': Attribute._sentinel,
'label': "", 'icon': "",
'can_reuse': ""}
tag_attrs['draggable'] = {
'id': Attribute._sentinel,
'label': "", 'icon': "",
'can_reuse': ""
}
tag_attrs['target'] = {'id': Attribute._sentinel,
'x': Attribute._sentinel,
'y': Attribute._sentinel,
'w': Attribute._sentinel,
'h': Attribute._sentinel}
tag_attrs['target'] = {
'id': Attribute._sentinel,
'x': Attribute._sentinel,
'y': Attribute._sentinel,
'w': Attribute._sentinel,
'h': Attribute._sentinel
}
dic = dict()

View File

@@ -23,9 +23,11 @@ from xmodule.combined_open_ended_module import CombinedOpenEndedModule
from xmodule.modulestore import Location
from xmodule.tests import get_test_system, test_util_open_ended
from xmodule.progress import Progress
from xmodule.tests.test_util_open_ended import (MockQueryDict, DummyModulestore, TEST_STATE_SA_IN,
from xmodule.tests.test_util_open_ended import (
MockQueryDict, DummyModulestore, TEST_STATE_SA_IN,
MOCK_INSTANCE_STATE, TEST_STATE_SA, TEST_STATE_AI, TEST_STATE_AI2, TEST_STATE_AI2_INVALID,
TEST_STATE_SINGLE, TEST_STATE_PE_SINGLE)
TEST_STATE_SINGLE, TEST_STATE_PE_SINGLE
)
import capa.xqueue_interface as xqueue_interface
@@ -69,7 +71,7 @@ class OpenEndedChildTest(unittest.TestCase):
'peer_grader_count': 1,
'min_to_calibrate': 3,
'max_to_calibrate': 6,
}
}
}
definition = Mock()
descriptor = Mock()
@@ -192,7 +194,7 @@ class OpenEndedModuleTest(unittest.TestCase):
'peer_grader_count': 1,
'min_to_calibrate': 3,
'max_to_calibrate': 6,
}
}
}
oeparam = etree.XML('''
@@ -553,7 +555,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
descriptor,
static_data=self.static_data,
metadata=self.metadata,
instance_state={'task_states' : TEST_STATE_SA})
instance_state={'task_states': TEST_STATE_SA})
combinedoe = CombinedOpenEndedV1Module(self.test_system,
self.location,
@@ -561,7 +563,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
descriptor,
static_data=self.static_data,
metadata=self.metadata,
instance_state={'task_states' : TEST_STATE_SA_IN})
instance_state={'task_states': TEST_STATE_SA_IN})
def test_get_score_realistic(self):
@@ -605,7 +607,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
descriptor = Mock(data=definition)
instance_state = {'task_states': task_state, 'graded': True}
if task_number is not None:
instance_state.update({'current_task_number' : task_number})
instance_state.update({'current_task_number': task_number})
combinedoe = CombinedOpenEndedV1Module(self.test_system,
self.location,
definition,
@@ -711,7 +713,7 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
#Simulate a student saving an answer
html = module.handle_ajax("get_html", {})
module.handle_ajax("save_answer", {"student_answer": self.answer, "can_upload_files" : False, "student_file" : None})
module.handle_ajax("save_answer", {"student_answer": self.answer, "can_upload_files": False, "student_file": None})
html = module.handle_ajax("get_html", {})
#Mock a student submitting an assessment