Commit 9f89112e by Muzaffar yousaf

Merge pull request #10419 from edx/muzaffar/pep8-fixes

Fix pep8 & pylint warnings.
parents d9751a85 35884195
...@@ -124,7 +124,10 @@ class CapaHtmlRenderTest(unittest.TestCase): ...@@ -124,7 +124,10 @@ class CapaHtmlRenderTest(unittest.TestCase):
rendered_html = etree.XML(problem.get_html()) rendered_html = etree.XML(problem.get_html())
# expect the javascript is still present in the rendered html # expect the javascript is still present in the rendered html
self.assertTrue("<script type=\"text/javascript\">function(){}</script>" in etree.tostring(rendered_html)) self.assertIn(
"<script type=\"text/javascript\">function(){}</script>",
etree.tostring(rendered_html) # pylint: disable=no-member
)
def test_render_response_xml(self): def test_render_response_xml(self):
# Generate some XML for a string response # Generate some XML for a string response
......
...@@ -105,8 +105,7 @@ class TemplateTestCase(unittest.TestCase): ...@@ -105,8 +105,7 @@ class TemplateTestCase(unittest.TestCase):
If no elements are found, the assertion fails. If no elements are found, the assertion fails.
""" """
element_list = xml_root.xpath(xpath) element_list = xml_root.xpath(xpath)
self.assertTrue(len(element_list) > 0, self.assertGreater(len(element_list), 0, "Could not find element at '%s'" % str(xpath))
"Could not find element at '%s'" % str(xpath))
if exact: if exact:
self.assertEqual(text, element_list[0].text) self.assertEqual(text, element_list[0].text)
......
...@@ -555,8 +555,8 @@ class MatlabTest(unittest.TestCase): ...@@ -555,8 +555,8 @@ class MatlabTest(unittest.TestCase):
response = self.the_input.handle_ajax("plot", data) response = self.the_input.handle_ajax("plot", data)
self.assertFalse(response['success']) self.assertFalse(response['success'])
self.assertEqual(response['message'], error_message) self.assertEqual(response['message'], error_message)
self.assertTrue('queuekey' not in self.the_input.input_state) self.assertNotIn('queuekey', self.the_input.input_state)
self.assertTrue('queuestate' not in self.the_input.input_state) self.assertNotIn('queuestate', self.the_input.input_state)
@patch('capa.inputtypes.time.time', return_value=10) @patch('capa.inputtypes.time.time', return_value=10)
def test_ungraded_response_success(self, time): def test_ungraded_response_success(self, time):
...@@ -594,7 +594,7 @@ class MatlabTest(unittest.TestCase): ...@@ -594,7 +594,7 @@ class MatlabTest(unittest.TestCase):
the_input.ungraded_response(queue_msg, 'abc') the_input.ungraded_response(queue_msg, 'abc')
self.assertEqual(input_state['queuekey'], queuekey) self.assertEqual(input_state['queuekey'], queuekey)
self.assertEqual(input_state['queuestate'], 'queued') self.assertEqual(input_state['queuestate'], 'queued')
self.assertFalse('queue_msg' in input_state) self.assertNotIn('queue_msg', input_state)
@patch('capa.inputtypes.time.time', return_value=20) @patch('capa.inputtypes.time.time', return_value=20)
def test_matlab_response_timeout_not_exceeded(self, time): def test_matlab_response_timeout_not_exceeded(self, time):
...@@ -1076,7 +1076,7 @@ class ChemicalEquationTest(unittest.TestCase): ...@@ -1076,7 +1076,7 @@ class ChemicalEquationTest(unittest.TestCase):
) )
self.assertIn('error', response) self.assertIn('error', response)
self.assertTrue("Couldn't parse formula" in response['error']) self.assertIn("Couldn't parse formula", response['error'])
@patch('capa.inputtypes.log') @patch('capa.inputtypes.log')
def test_ajax_other_err(self, mock_log): def test_ajax_other_err(self, mock_log):
......
...@@ -449,15 +449,14 @@ class CapaModuleTest(unittest.TestCase): ...@@ -449,15 +449,14 @@ class CapaModuleTest(unittest.TestCase):
# and that we get the same values back # and that we get the same values back
for key in result.keys(): for key in result.keys():
original_key = "input_" + key original_key = "input_" + key
self.assertTrue(original_key in valid_get_dict, self.assertIn(original_key, valid_get_dict, "Output dict should have key %s" % original_key)
"Output dict should have key %s" % original_key)
self.assertEqual(valid_get_dict[original_key], result[key]) self.assertEqual(valid_get_dict[original_key], result[key])
# Valid GET param dict with list keys # Valid GET param dict with list keys
# Each tuple represents a single parameter in the query string # Each tuple represents a single parameter in the query string
valid_get_dict = MultiDict((('input_2[]', 'test1'), ('input_2[]', 'test2'))) valid_get_dict = MultiDict((('input_2[]', 'test1'), ('input_2[]', 'test2')))
result = CapaModule.make_dict_of_responses(valid_get_dict) result = CapaModule.make_dict_of_responses(valid_get_dict)
self.assertTrue('2' in result) self.assertIn('2', result)
self.assertEqual(['test1', 'test2'], result['2']) self.assertEqual(['test1', 'test2'], result['2'])
# If we use [] at the end of a key name, we should always # If we use [] at the end of a key name, we should always
...@@ -730,7 +729,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -730,7 +729,7 @@ class CapaModuleTest(unittest.TestCase):
result = module.check_problem(get_request_dict) result = module.check_problem(get_request_dict)
# Expect an AJAX alert message in 'success' # Expect an AJAX alert message in 'success'
self.assertTrue(error_msg in result['success']) self.assertIn(error_msg, result['success'])
def test_check_problem_error_nonascii(self): def test_check_problem_error_nonascii(self):
...@@ -781,10 +780,10 @@ class CapaModuleTest(unittest.TestCase): ...@@ -781,10 +780,10 @@ class CapaModuleTest(unittest.TestCase):
result = module.check_problem(get_request_dict) result = module.check_problem(get_request_dict)
# Expect an AJAX alert message in 'success' # Expect an AJAX alert message in 'success'
self.assertTrue('test error' in result['success']) self.assertIn('test error', result['success'])
# We DO include traceback information for staff users # We DO include traceback information for staff users
self.assertTrue('Traceback' in result['success']) self.assertIn('Traceback', result['success'])
# Expect that the number of attempts is NOT incremented # Expect that the number of attempts is NOT incremented
self.assertEqual(module.attempts, 1) self.assertEqual(module.attempts, 1)
...@@ -806,7 +805,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -806,7 +805,7 @@ class CapaModuleTest(unittest.TestCase):
self.assertTrue('success' in result and result['success']) self.assertTrue('success' in result and result['success'])
# Expect that the problem HTML is retrieved # Expect that the problem HTML is retrieved
self.assertTrue('html' in result) self.assertIn('html', result)
self.assertEqual(result['html'], "<div>Test HTML</div>") self.assertEqual(result['html'], "<div>Test HTML</div>")
# Expect that the problem was reset # Expect that the problem was reset
...@@ -852,7 +851,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -852,7 +851,7 @@ class CapaModuleTest(unittest.TestCase):
self.assertEqual(result['success'], 'correct') self.assertEqual(result['success'], 'correct')
# Expect that we get no HTML # Expect that we get no HTML
self.assertFalse('contents' in result) self.assertNotIn('contents', result)
# Expect that the number of attempts is not incremented # Expect that the number of attempts is not incremented
self.assertEqual(module.attempts, 1) self.assertEqual(module.attempts, 1)
...@@ -1263,7 +1262,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -1263,7 +1262,7 @@ class CapaModuleTest(unittest.TestCase):
self.assertEqual(bool(context['save_button']), show_save_button) self.assertEqual(bool(context['save_button']), show_save_button)
# Assert that the encapsulated html contains the original html # Assert that the encapsulated html contains the original html
self.assertTrue(html in html_encapsulated) self.assertIn(html, html_encapsulated)
demand_xml = """ demand_xml = """
<problem> <problem>
...@@ -1355,7 +1354,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -1355,7 +1354,7 @@ class CapaModuleTest(unittest.TestCase):
# Check the rendering context # Check the rendering context
render_args, _ = module.system.render_template.call_args render_args, _ = module.system.render_template.call_args
context = render_args[1] context = render_args[1]
self.assertTrue("error" in context['problem']['html']) self.assertIn("error", context['problem']['html'])
# Expect that the module has created a new dummy problem with the error # Expect that the module has created a new dummy problem with the error
self.assertNotEqual(original_problem, module.lcp) self.assertNotEqual(original_problem, module.lcp)
...@@ -1385,7 +1384,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -1385,7 +1384,7 @@ class CapaModuleTest(unittest.TestCase):
# Check the rendering context # Check the rendering context
render_args, _ = module.system.render_template.call_args render_args, _ = module.system.render_template.call_args
context = render_args[1] context = render_args[1]
self.assertTrue(error_msg in context['problem']['html']) self.assertIn(error_msg, context['problem']['html'])
@ddt.data( @ddt.data(
'false', 'false',
......
...@@ -58,7 +58,11 @@ class OpenEndedChildTest(unittest.TestCase): ...@@ -58,7 +58,11 @@ class OpenEndedChildTest(unittest.TestCase):
rubric = '''<rubric><rubric> rubric = '''<rubric><rubric>
<category> <category>
<description>Response Quality</description> <description>Response Quality</description>
<option>The response is not a satisfactory answer to the question. It either fails to address the question or does so in a limited way, with no evidence of higher-order thinking.</option> <option>
The response is not a satisfactory answer to the question.
It either fails to address the question or does so in a limited way,
with no evidence of higher-order thinking.
</option>
<option>Second option</option> <option>Second option</option>
</category> </category>
</rubric></rubric>''' </rubric></rubric>'''
...@@ -183,7 +187,11 @@ class OpenEndedModuleTest(unittest.TestCase): ...@@ -183,7 +187,11 @@ class OpenEndedModuleTest(unittest.TestCase):
rubric = etree.XML('''<rubric> rubric = etree.XML('''<rubric>
<category> <category>
<description>Response Quality</description> <description>Response Quality</description>
<option>The response is not a satisfactory answer to the question. It either fails to address the question or does so in a limited way, with no evidence of higher-order thinking.</option> <option>
The response is not a satisfactory answer to the question.
It either fails to address the question or does so in a limited way,
with no evidence of higher-order thinking.
</option>
</category> </category>
</rubric>''') </rubric>''')
max_score = 4 max_score = 4
...@@ -212,7 +220,9 @@ class OpenEndedModuleTest(unittest.TestCase): ...@@ -212,7 +220,9 @@ class OpenEndedModuleTest(unittest.TestCase):
<openendedparam> <openendedparam>
<initial_display>Enter essay here.</initial_display> <initial_display>Enter essay here.</initial_display>
<answer_display>This is the answer.</answer_display> <answer_display>This is the answer.</answer_display>
<grader_payload>{"grader_settings" : "ml_grading.conf", "problem_id" : "6.002x/Welcome/OETest"}</grader_payload> <grader_payload>
{"grader_settings" : "ml_grading.conf", "problem_id" : "6.002x/Welcome/OETest"}
</grader_payload>
</openendedparam> </openendedparam>
''') ''')
definition = {'oeparam': oeparam} definition = {'oeparam': oeparam}
...@@ -365,9 +375,9 @@ class OpenEndedModuleTest(unittest.TestCase): ...@@ -365,9 +375,9 @@ class OpenEndedModuleTest(unittest.TestCase):
def test_latest_post_assessment(self): def test_latest_post_assessment(self):
self.update_score_single() self.update_score_single()
assessment = self.openendedmodule.latest_post_assessment(self.test_system) assessment = self.openendedmodule.latest_post_assessment(self.test_system)
self.assertFalse(assessment == '') self.assertNotEqual(assessment, '')
# check for errors # check for errors
self.assertFalse('errors' in assessment) self.assertNotIn('errors', assessment)
def test_update_score_single(self): def test_update_score_single(self):
self.update_score_single() self.update_score_single()
...@@ -466,7 +476,11 @@ class CombinedOpenEndedModuleTest(unittest.TestCase): ...@@ -466,7 +476,11 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
rubric = '''<rubric><rubric> rubric = '''<rubric><rubric>
<category> <category>
<description>Response Quality</description> <description>Response Quality</description>
<option>The response is not a satisfactory answer to the question. It either fails to address the question or does so in a limited way, with no evidence of higher-order thinking.</option> <option>
The response is not a satisfactory answer to the question.
It either fails to address the question or does so in a limited way,
with no evidence of higher-order thinking.
</option>
<option>Second option</option> <option>Second option</option>
</category> </category>
</rubric></rubric>''' </rubric></rubric>'''
...@@ -492,7 +506,9 @@ class CombinedOpenEndedModuleTest(unittest.TestCase): ...@@ -492,7 +506,9 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
<openendedparam> <openendedparam>
<initial_display>Enter essay here.</initial_display> <initial_display>Enter essay here.</initial_display>
<answer_display>This is the answer.</answer_display> <answer_display>This is the answer.</answer_display>
<grader_payload>{"grader_settings" : "ml_grading.conf", "problem_id" : "6.002x/Welcome/OETest"}</grader_payload> <grader_payload>
{"grader_settings" : "ml_grading.conf", "problem_id" : "6.002x/Welcome/OETest"}
</grader_payload>
</openendedparam> </openendedparam>
''') ''')
...@@ -511,7 +527,9 @@ class CombinedOpenEndedModuleTest(unittest.TestCase): ...@@ -511,7 +527,9 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
<openendedparam> <openendedparam>
<initial_display>Enter essay here.</initial_display> <initial_display>Enter essay here.</initial_display>
<answer_display>This is the answer.</answer_display> <answer_display>This is the answer.</answer_display>
<grader_payload>{"grader_settings" : "ml_grading.conf", "problem_id" : "6.002x/Welcome/OETest"}</grader_payload> <grader_payload>
{"grader_settings" : "ml_grading.conf", "problem_id" : "6.002x/Welcome/OETest"}
</grader_payload>
</openendedparam> </openendedparam>
</openended>''' </openended>'''
definition = {'prompt': etree.XML(prompt), 'rubric': etree.XML(rubric), 'task_xml': [task_xml1, task_xml2]} definition = {'prompt': etree.XML(prompt), 'rubric': etree.XML(rubric), 'task_xml': [task_xml1, task_xml2]}
...@@ -702,9 +720,18 @@ class CombinedOpenEndedModuleTest(unittest.TestCase): ...@@ -702,9 +720,18 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
<rubric> <rubric>
<category> <category>
<description>Response Quality</description> <description>Response Quality</description>
<option>The response is not a satisfactory answer to the question. It either fails to address the question or does so in a limited way, with no evidence of higher-order thinking.</option> <option>
<option>The response is a marginal answer to the question. It may contain some elements of a proficient response, but it is inaccurate or incomplete.</option> The response is not a satisfactory answer to the question. It either fails to address
<option>The response is a proficient answer to the question. It is generally correct, although it may contain minor inaccuracies. There is limited evidence of higher-order thinking.</option> the question or does so in a limited way, with no evidence of higher-order thinking.
</option>
<option>
The response is a marginal answer to the question. It may contain some elements of a
proficient response, but it is inaccurate or incomplete.
</option>
<option>
The response is a proficient answer to the question. It is generally correct, although
it may contain minor inaccuracies. There is limited evidence of higher-order thinking.
</option>
<option>The response is correct, complete, and contains evidence of higher-order thinking.</option> <option>The response is correct, complete, and contains evidence of higher-order thinking.</option>
</category> </category>
</rubric> </rubric>
...@@ -839,7 +866,10 @@ class CombinedOpenEndedModuleConsistencyTest(unittest.TestCase): ...@@ -839,7 +866,10 @@ class CombinedOpenEndedModuleConsistencyTest(unittest.TestCase):
rubric = '''<rubric><rubric> rubric = '''<rubric><rubric>
<category> <category>
<description>Response Quality</description> <description>Response Quality</description>
<option>The response is not a satisfactory answer to the question. It either fails to address the question or does so in a limited way, with no evidence of higher-order thinking.</option> <option>
The response is not a satisfactory answer to the question. It either fails to address the question
or does so in a limited way, with no evidence of higher-order thinking.
</option>
<option>Second option</option> <option>Second option</option>
</category> </category>
</rubric></rubric>''' </rubric></rubric>'''
...@@ -851,7 +881,9 @@ class CombinedOpenEndedModuleConsistencyTest(unittest.TestCase): ...@@ -851,7 +881,9 @@ class CombinedOpenEndedModuleConsistencyTest(unittest.TestCase):
<openendedparam> <openendedparam>
<initial_display>Enter essay here.</initial_display> <initial_display>Enter essay here.</initial_display>
<answer_display>This is the answer.</answer_display> <answer_display>This is the answer.</answer_display>
<grader_payload>{"grader_settings" : "ml_grading.conf", "problem_id" : "6.002x/Welcome/OETest"}</grader_payload> <grader_payload>
{"grader_settings" : "ml_grading.conf", "problem_id" : "6.002x/Welcome/OETest"}
</grader_payload>
</openendedparam> </openendedparam>
''') ''')
...@@ -870,7 +902,9 @@ class CombinedOpenEndedModuleConsistencyTest(unittest.TestCase): ...@@ -870,7 +902,9 @@ class CombinedOpenEndedModuleConsistencyTest(unittest.TestCase):
<openendedparam> <openendedparam>
<initial_display>Enter essay here.</initial_display> <initial_display>Enter essay here.</initial_display>
<answer_display>This is the answer.</answer_display> <answer_display>This is the answer.</answer_display>
<grader_payload>{"grader_settings" : "ml_grading.conf", "problem_id" : "6.002x/Welcome/OETest"}</grader_payload> <grader_payload>
{"grader_settings" : "ml_grading.conf", "problem_id" : "6.002x/Welcome/OETest"}
</grader_payload>
</openendedparam> </openendedparam>
</openended>''' </openended>'''
...@@ -1135,13 +1169,50 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore): ...@@ -1135,13 +1169,50 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
'queuekey': "", 'queuekey': "",
'xqueue_body': json.dumps({ 'xqueue_body': json.dumps({
'score': 0, 'score': 0,
'feedback': json.dumps({"spelling": "Spelling: Ok.", "grammar": "Grammar: Ok.", 'feedback': json.dumps({
"markup-text": " all of us can think of a book that we hope none of our children or any other children have taken off the shelf . but if i have the right to remove that book from the shelf that work i abhor then you also have exactly the same right and so does everyone else . and then we <bg>have no books left</bg> on the shelf for any of us . <bs>katherine</bs> <bs>paterson</bs> , author write a persuasive essay to a newspaper reflecting your vies on censorship <bg>in libraries . do</bg> you believe that certain materials , such as books , music , movies , magazines , <bg>etc . , should be</bg> removed from the shelves if they are found <bg>offensive ? support your</bg> position with convincing arguments from your own experience , observations <bg>, and or reading .</bg> "}), "spelling": "Spelling: Ok.",
"grammar": "Grammar: Ok.",
"markup-text": " all of us can think of a book that we hope none of our children or any other "
"children have taken off the shelf . but if i have the right to remove that book "
"from the shelf that work i abhor then you also have exactly the same right and "
"so does everyone else . and then we <bg>have no books left</bg> "
"on the shelf for any of us . <bs>katherine</bs> <bs>paterson</bs> , author "
"write a persuasive essay to a newspaper reflecting your vies on censorship "
"<bg>in libraries . do</bg> you believe that certain materials , such as books , "
"music , movies , magazines , <bg>etc . , should be</bg> removed from the shelves "
"if they are found <bg>offensive ? support your</bg> position with convincing "
"arguments from your own experience , observations <bg>, and or reading .</bg> "
}),
'grader_type': "ML", 'grader_type': "ML",
'success': True, 'success': True,
'grader_id': 1, 'grader_id': 1,
'submission_id': 1, 'submission_id': 1,
'rubric_xml': "<rubric><category><description>Writing Applications</description><score>0</score><option points='0'> The essay loses focus, has little information or supporting details, and the organization makes it difficult to follow.</option><option points='1'> The essay presents a mostly unified theme, includes sufficient information to convey the theme, and is generally organized well.</option></category><category><description> Language Conventions </description><score>0</score><option points='0'> The essay demonstrates a reasonable command of proper spelling and grammar. </option><option points='1'> The essay demonstrates superior command of proper spelling and grammar.</option></category></rubric>", 'rubric_xml': '''
<rubric>
<category>
<description>Writing Applications</description>
<score>0</score>
<option points='0'>
The essay loses focus, has little information or supporting details, and the
organization makes it difficult to follow.
</option>
<option points='1'>
The essay presents a mostly unified theme, includes sufficient information to convey
the theme, and is generally organized well.
</option>
</category>
<category>
<description> Language Conventions </description>
<score>0</score>
<option points='0'>
The essay demonstrates a reasonable command of proper spelling and grammar.
</option>
<option points='1'>
The essay demonstrates superior command of proper spelling and grammar.
</option>
</category>
</rubric>
''',
'rubric_scores_complete': True, 'rubric_scores_complete': True,
}) })
} }
...@@ -1202,13 +1273,49 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore): ...@@ -1202,13 +1273,49 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
'queuekey': "", 'queuekey': "",
'xqueue_body': json.dumps({ 'xqueue_body': json.dumps({
'score': 0, 'score': 0,
'feedback': json.dumps({"spelling": "Spelling: Ok.", "grammar": "Grammar: Ok.", 'feedback': json.dumps({
"markup-text": " all of us can think of a book that we hope none of our children or any other children have taken off the shelf . but if i have the right to remove that book from the shelf that work i abhor then you also have exactly the same right and so does everyone else . and then we <bg>have no books left</bg> on the shelf for any of us . <bs>katherine</bs> <bs>paterson</bs> , author write a persuasive essay to a newspaper reflecting your vies on censorship <bg>in libraries . do</bg> you believe that certain materials , such as books , music , movies , magazines , <bg>etc . , should be</bg> removed from the shelves if they are found <bg>offensive ? support your</bg> position with convincing arguments from your own experience , observations <bg>, and or reading .</bg> "}), "spelling": "Spelling: Ok.", "grammar": "Grammar: Ok.",
"markup-text": " all of us can think of a book that we hope none of our children or any other "
"children have taken off the shelf . but if i have the right to remove that book "
"from the shelf that work i abhor then you also have exactly the same right and "
"so does everyone else . and then we <bg>have no books left</bg> on the shelf for "
"any of us . <bs>katherine</bs> <bs>paterson</bs> , author write a persuasive essay "
"to a newspaper reflecting your vies on censorship <bg>in libraries . do</bg> "
"you believe that certain materials , such as books , music , movies , magazines , "
"<bg>etc . , should be</bg> removed from the shelves if they are found "
"<bg>offensive ? support your</bg> position with convincing arguments from your "
"own experience , observations <bg>, and or reading .</bg> "
}),
'grader_type': "ML", 'grader_type': "ML",
'success': True, 'success': True,
'grader_id': 1, 'grader_id': 1,
'submission_id': 1, 'submission_id': 1,
'rubric_xml': "<rubric><category><description>Writing Applications</description><score>0</score><option points='0'> The essay loses focus, has little information or supporting details, and the organization makes it difficult to follow.</option><option points='1'> The essay presents a mostly unified theme, includes sufficient information to convey the theme, and is generally organized well.</option></category><category><description> Language Conventions </description><score>0</score><option points='0'> The essay demonstrates a reasonable command of proper spelling and grammar. </option><option points='1'> The essay demonstrates superior command of proper spelling and grammar.</option></category></rubric>", 'rubric_xml': '''
<rubric>
<category>
<description>Writing Applications</description>
<score>0</score>
<option points='0'>
The essay loses focus, has little information or supporting details, and
the organization makes it difficult to follow.
</option>
<option points='1'>
The essay presents a mostly unified theme, includes sufficient
information to convey the theme, and is generally organized well.
</option>
</category>
<category>
<description> Language Conventions </description>
<score>0</score>
<option points='0'>
The essay demonstrates a reasonable command of proper spelling and grammar.
</option>
<option points='1'>
The essay demonstrates superior command of proper spelling and grammar.
</option>
</category>
</rubric>
''',
'rubric_scores_complete': True, 'rubric_scores_complete': True,
}) })
} }
......
...@@ -554,9 +554,9 @@ class CrowdsourceHinterTest(unittest.TestCase): ...@@ -554,9 +554,9 @@ class CrowdsourceHinterTest(unittest.TestCase):
mock_module.get_hint = fake_get_hint mock_module.get_hint = fake_get_hint
json_in = {'problem_name': '42.5'} json_in = {'problem_name': '42.5'}
out = json.loads(mock_module.handle_ajax('get_hint', json_in))['contents'] out = json.loads(mock_module.handle_ajax('get_hint', json_in))['contents']
self.assertTrue('This is the best hint.' in out) self.assertIn('This is the best hint.', out)
self.assertTrue('A random hint' in out) self.assertIn('A random hint', out)
self.assertTrue('Another random hint' in out) self.assertIn('Another random hint', out)
def test_template_feedback(self): def test_template_feedback(self):
""" """
......
...@@ -225,18 +225,18 @@ class ImportTestCase(BaseCourseTestCase): ...@@ -225,18 +225,18 @@ class ImportTestCase(BaseCourseTestCase):
self.assertEqual(course_xml.attrib['unicorn'], unicorn_color) self.assertEqual(course_xml.attrib['unicorn'], unicorn_color)
# the course and org tags should be _only_ in the pointer # the course and org tags should be _only_ in the pointer
self.assertTrue('course' not in course_xml.attrib) self.assertNotIn('course', course_xml.attrib)
self.assertTrue('org' not in course_xml.attrib) self.assertNotIn('org', course_xml.attrib)
# did we successfully strip the url_name from the definition contents? # did we successfully strip the url_name from the definition contents?
self.assertTrue('url_name' not in course_xml.attrib) self.assertNotIn('url_name', course_xml.attrib)
# Does the chapter tag now have a due attribute? # Does the chapter tag now have a due attribute?
# hardcoded path to child # hardcoded path to child
with descriptor.runtime.export_fs.open('chapter/ch.xml') as f: with descriptor.runtime.export_fs.open('chapter/ch.xml') as f:
chapter_xml = etree.fromstring(f.read()) chapter_xml = etree.fromstring(f.read())
self.assertEqual(chapter_xml.tag, 'chapter') self.assertEqual(chapter_xml.tag, 'chapter')
self.assertFalse('due' in chapter_xml.attrib) self.assertNotIn('due', chapter_xml.attrib)
def test_metadata_import_export(self): def test_metadata_import_export(self):
"""Two checks: """Two checks:
......
...@@ -127,12 +127,12 @@ class ProgressTest(unittest.TestCase): ...@@ -127,12 +127,12 @@ class ProgressTest(unittest.TestCase):
prg1 = Progress(1, 2) prg1 = Progress(1, 2)
prg2 = Progress(2, 4) prg2 = Progress(2, 4)
prg3 = Progress(1, 2) prg3 = Progress(1, 2)
self.assertTrue(prg1 == prg3) self.assertEqual(prg1, prg3)
self.assertFalse(prg1 == prg2) self.assertNotEqual(prg1, prg2)
# Check != while we're at it # Check != while we're at it
self.assertTrue(prg1 != prg2) self.assertNotEqual(prg1, prg2)
self.assertFalse(prg1 != prg3) self.assertEqual(prg1, prg3)
class ModuleProgressTest(unittest.TestCase): class ModuleProgressTest(unittest.TestCase):
......
...@@ -78,7 +78,7 @@ class SelfAssessmentTest(unittest.TestCase): ...@@ -78,7 +78,7 @@ class SelfAssessmentTest(unittest.TestCase):
def test_get_html(self): def test_get_html(self):
html = self.module.get_html(self.module.system) html = self.module.get_html(self.module.system)
self.assertTrue("This is sample prompt text" in html) self.assertIn("This is sample prompt text", html)
def test_self_assessment_flow(self): def test_self_assessment_flow(self):
responses = {'assessment': '0', 'score_list[]': ['0', '0']} responses = {'assessment': '0', 'score_list[]': ['0', '0']}
......
...@@ -642,7 +642,7 @@ class CreditProviderIntegrationApiTests(CreditApiTestBase): ...@@ -642,7 +642,7 @@ class CreditProviderIntegrationApiTests(CreditApiTestBase):
# Validate the timestamp # Validate the timestamp
self.assertIn('timestamp', parameters) self.assertIn('timestamp', parameters)
parsed_date = from_timestamp(parameters['timestamp']) parsed_date = from_timestamp(parameters['timestamp'])
self.assertTrue(parsed_date < datetime.datetime.now(pytz.UTC)) self.assertLess(parsed_date, datetime.datetime.now(pytz.UTC))
# Validate course information # Validate course information
self.assertEqual(parameters['course_org'], self.course_key.org) self.assertEqual(parameters['course_org'], self.course_key.org)
......
...@@ -80,7 +80,7 @@ class TestAccountApi(UserSettingsEventTestMixin, TestCase): ...@@ -80,7 +80,7 @@ class TestAccountApi(UserSettingsEventTestMixin, TestCase):
# With default configuration settings, email is not shared with other (non-staff) users. # With default configuration settings, email is not shared with other (non-staff) users.
account_settings = get_account_settings(self.default_request, self.different_user.username) account_settings = get_account_settings(self.default_request, self.different_user.username)
self.assertFalse("email" in account_settings) self.assertNotIn("email", account_settings)
account_settings = get_account_settings( account_settings = get_account_settings(
self.default_request, self.default_request,
......
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