Beispiel #1
0
 def test_fail_if2(self):
     self.data["DC_SCT"] = 'test_object("i")'
     sct_payload = helper.run(self.data)
     self.assertFalse(sct_payload['correct'])
     self.assertEqual(sct_payload['message'],
                      "The contents of <code>i</code> aren't correct.")
     helper.test_absent_lines(self, sct_payload)
 def test_step1(self):
     self.data["DC_CODE"] = ""
     sct_payload = helper.run(self.data)
     self.assertFalse(sct_payload['correct'])
     self.assertIn('Have you called <code>x.center()</code>?',
                   sct_payload['message'])
     helper.test_absent_lines(self, sct_payload)
 def test_multiple_6(self):
     self.data["DC_CODE"] = 'print("abc")\nprint(123)\nprint([1, 2, 3, 4])'
     sct_payload = helper.run(self.data)
     self.assertFalse(sct_payload['correct'])
     self.assertIn(
         "Did you call <code>print()</code> with the correct arguments?",
         sct_payload['message'])
     helper.test_absent_lines(self, sct_payload)
Beispiel #4
0
    def test_Fail2_no_lam(self):
        self.data["DC_SCT"] = '''
test_with(1, body = [test_function('print', index = i + 1) for i in range(3)], expand_message = False)
success_msg("Nice work!")
        '''
        sct_payload = helper.run(self.data)
        self.assertFalse(sct_payload['correct'])
        self.assertNotIn("Check the body of the first <code>with</code>.",
                         sct_payload['message'])
        # line info should be specific to test_function
        helper.test_absent_lines(self, sct_payload)
Beispiel #5
0
    def test_Fail1_spec2(self):
        self.data["DC_SCT"] = '''
Ex().check_with(0).check_body().with_context([test_function('print', index = i+1) for i in range(3)])
        '''
        sct_payload = helper.run(self.data)
        self.assertFalse(sct_payload['correct'])
        self.assertIn(
            "Check the body of the first <code>with</code> statement.",
            sct_payload['message'])
        # line info should be specific to test_function
        helper.test_absent_lines(self, sct_payload)
	def test_enrichment_error(self):
		self.data = {
			"DC_PEC": '# no pec',
			"DC_CODE": '',
			"DC_SOLUTION": 'x = 6',
			"DC_SCT": 'test_object("x")'
		}
		self.exercise = Exercise(self.data)
		self.exercise.runInit()
		output = self.exercise.runSubmit(self.data)
		self.assertEqual(output[0]['type'], 'sct')
		self.assertFalse(output[0]['payload']['correct'])
		helper.test_absent_lines(self, output[0]['payload'])
 def test_enrichment_error(self):
     self.data = {
         "DC_PEC": '# no pec',
         "DC_CODE": '',
         "DC_SOLUTION": 'x = 6',
         "DC_SCT": 'test_object("x")'
     }
     self.exercise = Exercise(self.data)
     self.exercise.runInit()
     output = self.exercise.runSubmit(self.data)
     self.assertEqual(output[0]['type'], 'sct')
     self.assertFalse(output[0]['payload']['correct'])
     helper.test_absent_lines(self, output[0]['payload'])
 def test_step1(self):
     self.data["DC_CODE"] = ""
     sct_payload = helper.run(self.data)
     self.assertFalse(sct_payload['correct'])
     self.assertEqual('notcalledmsg', sct_payload['message'])
     helper.test_absent_lines(self, sct_payload)
 def test_step1(self):
     self.data["DC_CODE"] = ""
     sct_payload = helper.run(self.data)
     self.assertFalse(sct_payload['correct'])
     helper.test_absent_lines(self, sct_payload)
Beispiel #10
0
 def test_fail(self):
     self.data["DC_SCT"] = 'test_object("df2")'
     sct_payload = helper.run(self.data)
     self.assertFalse(sct_payload['correct'])
     helper.test_absent_lines(self, sct_payload)
 def test_step1(self):
     self.data["DC_CODE"] = ""
     sct_payload = helper.run(self.data)
     self.assertFalse(sct_payload['correct'])
     self.assertIn('Have you called <code>print()</code>?', sct_payload['message'])
     helper.test_absent_lines(self, sct_payload)
 def test_step1(self):
     self.data["DC_CODE"] = ""
     sct_payload = helper.run(self.data)
     self.assertFalse(sct_payload['correct'])
     self.assertEqual('notcalledmsg', sct_payload['message'])
     helper.test_absent_lines(self, sct_payload)
Beispiel #13
0
 def test_fail(self):
     self.data["DC_SCT"] = 'Ex().check_object("df2").has_equal_value()'
     sct_payload = helper.run(self.data)
     self.assertFalse(sct_payload['correct'])
     helper.test_absent_lines(self, sct_payload)
Beispiel #14
0
 def test_fail(self):
     self.data["DC_SCT"] = 'test_object("df2")'
     sct_payload = helper.run(self.data)
     self.assertFalse(sct_payload["correct"])
     helper.test_absent_lines(self, sct_payload)
Beispiel #15
0
 def test_fail_if2(self):
     self.data["DC_SCT"] = 'test_object("i")'
     sct_payload = helper.run(self.data)
     self.assertFalse(sct_payload["correct"])
     self.assertEqual(sct_payload["message"], "The contents of <code>i</code> aren't correct.")
     helper.test_absent_lines(self, sct_payload)